Skip to content

🐛 server: prefer latest document for manteca#813

Merged
cruzdanilo merged 1 commit intomainfrom
latest
Feb 19, 2026
Merged

🐛 server: prefer latest document for manteca#813
cruzdanilo merged 1 commit intomainfrom
latest

Conversation

@mainqueg
Copy link
Contributor

@mainqueg mainqueg commented Feb 19, 2026


Open with Devin

Greptile Summary

fixed document selection logic in getValidDocumentForManteca to prefer the latest document by reversing iteration order. when multiple documents of the same class exist (e.g., multiple ids), the function now checks the most recently added document first, falling back to earlier ones only if the latest is invalid.

  • changed server/utils/persona.ts:456 to iterate documents in reverse order using .toReversed()
  • updated test expectations to reflect new behavior (now expects 1 fetch instead of 2 when latest document is valid)
  • added new test cases covering latest document preference for both valid and fallback scenarios

Confidence Score: 5/5

  • this pr is safe to merge with minimal risk
  • the change is minimal (single method call), well-tested with comprehensive test coverage including edge cases, and the logic is straightforward. the fix correctly addresses the issue of preferring the latest document.
  • no files require special attention

Important Files Changed

Filename Overview
.changeset/petite-days-ring.md standard changeset file documenting the bug fix
server/utils/persona.ts added .toReversed() to prefer latest document when checking manteca eligibility
server/test/utils/persona.test.ts updated and added tests to verify latest document preference behavior

Last reviewed commit: 77098a5

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Updated document selection logic to prioritize the latest document version when multiple documents of the same class exist with valid photos.

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 77098a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link

Summary of Changes

Hello @mainqueg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the server's document evaluation logic for Manteca, ensuring that when multiple documents of the same class exist, the system correctly identifies and prioritizes the most recently submitted valid document. This change improves the accuracy and efficiency of the document verification process by streamlining the selection mechanism.

Highlights

  • Bug Fix: Document Preference: Resolved an issue where the system did not consistently prefer the latest document when evaluating for Manteca, ensuring that the most recent valid document is selected.
  • Logic Update: Modified the getValidDocumentForManteca function to iterate through documents in reverse order, effectively prioritizing the latest available documents for evaluation.
  • Test Suite Enhancements: Updated existing test cases and added new ones to accurately reflect the new logic, including scenarios for preferring the latest valid document and falling back to earlier ones if the latest is incomplete.
Changelog
  • @exactly/server
    • 🐛 prefer latest document for manteca
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Walkthrough

This PR modifies document selection logic for Manteca ID verification by changing the iteration order to prefer the latest document with valid photos when multiple documents share the same id_class. The change includes a changeset file, updated tests, and a one-line implementation change reversing the array traversal order.

Changes

Cohort / File(s) Summary
Changeset metadata
.changeset/petite-days-ring.md
Patch version bump for "@exactly/server" documenting the Manteca document selection preference fix.
Persona document selection
server/utils/persona.ts
Reversed array traversal in classDocuments loop (toReversed()) to prioritize the latest document with valid photos when multiple documents share the same id_class.
Test coverage
server/test/utils/persona.test.ts
Added comprehensive test scenarios validating the latest document preference: confirmed latest document selection when photos are present, fallback to earlier documents when latest lacks photos, and latest pp document selection without unnecessary fetch calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • nfmelendez
  • cruzdanilo
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: reversing document iteration to prefer the latest document for manteca selection, which is the core modification across all changed files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch latest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cruzdanilo cruzdanilo marked this pull request as ready for review February 19, 2026 22:20
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

@sentry
Copy link

sentry bot commented Feb 19, 2026

✅ All tests passed.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request correctly implements the logic to prefer the latest document for Manteca verification. A comment has been added regarding the use of .toReversed() for better Node.js version compatibility and efficiency, suggesting the use of .reverse() instead.

@cruzdanilo cruzdanilo merged commit 77098a5 into main Feb 19, 2026
14 of 16 checks passed
@cruzdanilo cruzdanilo deleted the latest branch February 19, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments