| Conditions | 1 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | { |
||
| 17 | 10 | $connection = $this->getEntityManager()->getConnection(); |
|
| 18 | |||
| 19 | $sqlUpgrade = <<<STRING |
||
| 20 | 10 | UPDATE user |
|
| 21 | INNER JOIN ( |
||
| 22 | SELECT user.email, MAX(product.review_number) AS bestReviewNumber |
||
| 23 | FROM organization |
||
| 24 | INNER JOIN product ON organization.subscription_last_review_id = product.id |
||
| 25 | INNER JOIN user ON user.email REGEXP organization.pattern |
||
| 26 | GROUP BY user.email |
||
| 27 | ) AS bestMatch ON user.email = bestMatch.email |
||
| 28 | INNER JOIN product AS orgProduct ON orgProduct.review_number = bestMatch.bestReviewNumber |
||
| 29 | LEFT JOIN product AS userProduct ON userProduct.id = user.subscription_last_review_id |
||
| 30 | SET |
||
| 31 | user.subscription_last_review_id = IF(userProduct.id IS NULL OR orgProduct.review_number > userProduct.review_number, orgProduct.id, userProduct.id), |
||
| 32 | user.subscription_type = IF(user.subscription_type IN ('paper', 'both'), 'both', 'digital') |
||
| 33 | STRING; |
||
| 34 | |||
| 35 | 10 | $connection->executeUpdate($sqlUpgrade); |
|
| 38 |