betagouv / preuve-covoiturage

Registre de preuve de covoiturage
https://app.covoiturage.beta.gouv.fr
Apache License 2.0
34 stars 12 forks source link

Ajout de la campagne PMGFxATMB 2024 #2480

Closed jonathanfallon closed 6 months ago

jonathanfallon commented 6 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 6 months ago

Walkthrough

The updates primarily involve renaming the function startAndEndAtOrThrow to startsAndEndsAtOrThrow across several policy files, enhancing the sorting mechanism in getOperatorsAt, and introducing new functions and tests related to policy validation. The changes ensure consistency in function naming and improve the reliability of date handling and territorial checks within the policy engine.

Changes

Files Summary
.../getOperatorsAt.spec.ts, .../getOperatorsAt.ts Enhanced sorting by date and added tests for missing properties.
.../startsAndEndsAtOrThrow.*, .../startsOrEndsAtOrThrow.* Renamed function from startAndEndAtOrThrow to startsAndEndsAtOrThrow and added new tests and functionality for territorial checks.
.../policies/*.ts, .../policies/*.spec.ts Updated multiple policy files with the renamed function and introduced new policy handler PMGFxATMB2024.
.../position.ts Added new function startsOrEndsAt for checking condition boundaries.
.../policies/index.ts Added new policy PMGFxATMB2024 to the policies map.

🐰✨🌟
In the land of code where the functions play,
A rabbit hopped through, renaming away.
From startAndEnd to startsAndEnds it goes,
Sorting dates and checks, as the policy flows.
Hop, skip, a jump! New tests in the fray,
Making code cleaner by night and by day. 🌙📝
🐰✨🌟


Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between acb90c180ff311754f75d7b7fbe7cba430c0c0a7 and 718da11eb31a1292aa526ad48b6cc0774698de86.
Files selected for processing (17) * api/src/pdc/services/policy/engine/helpers/getOperatorsAt.spec.ts (2 hunks) * api/src/pdc/services/policy/engine/helpers/getOperatorsAt.ts (1 hunks) * api/src/pdc/services/policy/engine/helpers/position.ts (1 hunks) * api/src/pdc/services/policy/engine/helpers/startsAndEndsAtOrThrow.spec.ts (3 hunks) * api/src/pdc/services/policy/engine/helpers/startsAndEndsAtOrThrow.ts (1 hunks) * api/src/pdc/services/policy/engine/helpers/startsOrEndsAtOrThrow.spec.ts (1 hunks) * api/src/pdc/services/policy/engine/helpers/startsOrEndsAtOrThrow.ts (1 hunks) * api/src/pdc/services/policy/engine/policies/ATMB202305.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/GrandPoitiers.spec.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/MetropoleSavoie.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/Nm.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/Occitanie20232024.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.html.ts (1 hunks) * api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.spec.ts (1 hunks) * api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.ts (1 hunks) * api/src/pdc/services/policy/engine/policies/PetrLunevilloisS12023.ts (2 hunks) * api/src/pdc/services/policy/engine/policies/index.ts (3 hunks)
Files skipped from review due to trivial changes (1) * api/src/pdc/services/policy/engine/helpers/startsAndEndsAtOrThrow.spec.ts
Additional comments not posted (22)
api/src/pdc/services/policy/engine/helpers/startsAndEndsAtOrThrow.ts (1)
`5-5`: Function implementation aligns with the described functionality.
api/src/pdc/services/policy/engine/helpers/startsOrEndsAtOrThrow.ts (1)
`5-5`: Function implementation aligns with the described functionality.
api/src/pdc/services/policy/engine/helpers/getOperatorsAt.ts (1)
`9-25`: Sorting and date handling logic are correctly implemented and improve the functionality.
api/src/pdc/services/policy/engine/helpers/startsOrEndsAtOrThrow.spec.ts (1)
`12-32`: Test cases are comprehensive and correctly implemented.
api/src/pdc/services/policy/engine/helpers/position.ts (1)
`26-26`: New helper function correctly implements the required functionality.
api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.html.ts (1)
`2-42`: HTML content is well-formatted and accurately describes the campaign rules.
api/src/pdc/services/policy/engine/policies/MetropoleSavoie.ts (1)
Line range hint `18-43`: Policy handler updates correctly integrate the renamed function and maintain consistency with the campaign rules.
api/src/pdc/services/policy/engine/policies/PetrLunevilloisS12023.ts (1)
Line range hint `20-50`: Policy handler updates correctly integrate the renamed function and maintain consistency with the campaign rules.
api/src/pdc/services/policy/engine/policies/index.ts (2)
`17-17`: Import of `PMGFxATMB2024` correctly added. --- `63-63`: Addition of `PMGFxATMB2024` to the policies map is correct and follows the existing pattern.
api/src/pdc/services/policy/engine/policies/Nm.ts (1)
`22-22`: Updated import path for `startsAndEndsAtOrThrow` is correct.
api/src/pdc/services/policy/engine/policies/ATMB202305.ts (2)
`21-21`: Updated import path for `startsAndEndsAtOrThrow` is correct. --- `76-76`: Conditional usage of `startsAndEndsAtOrThrow` based on `policy_change_date` is implemented correctly.
api/src/pdc/services/policy/engine/policies/Occitanie20232024.ts (1)
`20-20`: Updated import path for `startsAndEndsAtOrThrow` is correct.
api/src/pdc/services/policy/engine/helpers/getOperatorsAt.spec.ts (3)
`26-29`: New test for handling missing operators property is correctly implemented. --- `31-34`: New test for handling missing date property is correctly implemented. --- `62-100`: Tests for sorting operators in chronological order are correctly implemented and cover various scenarios.
api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.ts (1)
`1-149`: The implementation of the `PMGFxATMB2024` policy handler is correct. It includes proper imports, class definition, and methods for processing exclusions and stateless operations. The incentive calculation logic matches the campaign's rules.
api/src/pdc/services/policy/engine/policies/GrandPoitiers.spec.ts (1)
Line range hint `51-61`: New test for handling exclusions in the `GrandPoitiers` policy handler is correctly implemented.
api/src/pdc/services/policy/engine/policies/PMGFxATMB2024.spec.ts (3)
`48-98`: New test for handling exclusions in the `PMGFxATMB2024` policy handler is correctly implemented. --- `100-172`: Tests for trips inside and outside the AOM in the `PMGFxATMB2024` policy handler are correctly implemented and cover various scenarios. --- `174-202`: Test for handling driver month limits in the `PMGFxATMB2024` policy handler is correctly implemented.
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.