| Conditions | 5 |
| Paths | 6 |
| Total Lines | 46 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 13 | public function run() |
||
| 14 | { |
||
| 15 | $psvDoubledSlugs = \Yii::$app->cache->get('psvDoubledSlugs:data'); |
||
| 16 | if ($psvDoubledSlugs === false) { |
||
| 17 | $psvDoubledSlugs = PropertyStaticValues::find() |
||
| 18 | ->select(['slug']) |
||
| 19 | ->groupBy('slug') |
||
| 20 | ->having('COUNT(*) > 1') |
||
| 21 | ->indexBy('slug') |
||
| 22 | ->column(); |
||
| 23 | if (count($psvDoubledSlugs) > 0) { |
||
| 24 | foreach ($psvDoubledSlugs as $psvSlug) { |
||
| 25 | $psvDoubledSlugs[$psvSlug] = Property::find() |
||
| 26 | ->select(['id', 'name', 'property_group_id']) |
||
| 27 | ->asArray(true) |
||
| 28 | ->where( |
||
| 29 | [ |
||
| 30 | 'id' => PropertyStaticValues::find() |
||
| 31 | ->select('property_id') |
||
| 32 | ->where(['slug' => $psvSlug]) |
||
| 33 | ->column() |
||
| 34 | ] |
||
| 35 | ) |
||
| 36 | ->all();; |
||
|
|
|||
| 37 | } |
||
| 38 | \Yii::$app->cache->set( |
||
| 39 | 'psvDoubledSlugs', |
||
| 40 | $psvDoubledSlugs, |
||
| 41 | 86400, |
||
| 42 | new TagDependency( |
||
| 43 | [ |
||
| 44 | 'tags' => ActiveRecordHelper::getCommonTag(PropertyStaticValues::class) |
||
| 45 | ] |
||
| 46 | ) |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | if (count($psvDoubledSlugs) > 0) { |
||
| 51 | echo $this->render( |
||
| 52 | 'doubles-finder', |
||
| 53 | [ |
||
| 54 | 'psvDoubledSlugs' => $psvDoubledSlugs |
||
| 55 | ] |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
Let’s take a look at an example: