Commit c3b49c7b authored by Okhin's avatar Okhin
Browse files

A better SQL command return ONLY the bigger ordered item by user_id and day

parent 43da7c56
......@@ -131,8 +131,8 @@ EOF;
// Those are the parents ID, grouped by day.
$parents = $this->connection->executeQuery(
"select id from contreparties WHERE user_id = :user_id group by user_id, dayofyear(datec) order by field(quoi, 'piplome', 'pibag', 'pishirt', 'hoodie')",
[ 'user_id' => $user_id]
"SELECT id FROM contreparties c JOIN (SELECT MAX(FIELD(quoi, 'piplome', 'pibag', 'pishirt', 'hoodie')) m FROM contreparties GROUP BY user_id, dayofyear(datec)) AS m WHERE FIELD(c.quoi, 'piplome', 'pibag', 'pishirt', 'hoodie') = m.m AND user_id = :user_id",
[ 'user_id' => $user_id ]
foreach ($parents as $parent) {
......@@ -15,7 +15,7 @@ class CounterpartHandlerTest extends FunctionalTest
$this->container['command_handler']->handle(new AdminUpdateParentCommand());
$target = $this->container['counterpart_finder']->findById(4);
$this->assertSame((int) $target['parent'], 2);
$this->assertSame((int) $target['parent'], 4);
public function testCounterpartDelete()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment