Skip to content

Commit

Permalink
Merge pull request #1328 from betagouv/fix/policy
Browse files Browse the repository at this point in the history
fix(policy): avoid conflict when multiple campaign on same territory
  • Loading branch information
jonathanfallon authored Apr 21, 2021
2 parents d09464d + 45f9d2a commit 2a9e0ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/services/policy/src/providers/TripRepositoryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export class TripRepositoryProvider implements TripRepositoryProviderInterface {
)
) as people
FROM ${this.table} as pt
LEFT JOIN policy.incentives as pi ON pi.carpool_id = pt.carpool_id
LEFT JOIN policy.incentives as pi
ON pi.carpool_id = pt.carpool_id
AND pi.policy_id = $4::int
WHERE pt.datetime >= $1::timestamp AND pt.datetime <= $2::timestamp
AND pt.carpool_status = 'ok'::carpool.carpool_status_enum
AND (
Expand All @@ -68,7 +70,7 @@ export class TripRepositoryProvider implements TripRepositoryProviderInterface {
GROUP BY pt.trip_id
ORDER BY min(pt.datetime) ASC
`,
values: [policy.start_date, policy.end_date, policy.territory_id],
values: [policy.start_date, policy.end_date, policy.territory_id, policy.policy_id],
};

const client = await this.connection.getClient().connect();
Expand Down

0 comments on commit 2a9e0ff

Please sign in to comment.