Commit 36f0ff61 authored by okhin's avatar okhin 🚴

Merge branch '78-souci-sur-solde-des-donateurs' into 'preprod'

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

Closes #78

See merge request !91
parents 4f9b9558 c3b49c7b
Pipeline #2339 passed with stages
in 1 minute and 45 seconds
......@@ -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 ]
)->fetchAll(\PDO::FETCH_COLUMN);
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()
......
Markdown is supported
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