Skip to content

fix: imageNames sorting to preserve descending timestamp order#5461

Open
gabbyemsden wants to merge 1 commit intoopenfoodfacts:developfrom
gabbyemsden:fix/image-names-sorting-5013
Open

fix: imageNames sorting to preserve descending timestamp order#5461
gabbyemsden wants to merge 1 commit intoopenfoodfacts:developfrom
gabbyemsden:fix/image-names-sorting-5013

Conversation

@gabbyemsden
Copy link
Copy Markdown

Description

Fixes #5013 - Image names sorting by upload time

This PR fixes the failing test in ProductPhotosViewModelTest where imageNames should return image names sorted by upload timestamp in descending order (newest first).

Changes Made

  • Added explicit .sortedByDescending { it.timestamp } in ProductPhotosViewModel to ensure images are returned in the correct order
  • Ensures sort order is preserved through Flow transformations
  • The ImageNameParser.extractImageNames() already returns sorted data, but this ensures the order is maintained through the reactive Flow pipeline

Testing

  • The fix addresses the failing test: ProductPhotosViewModelTest > Given product api returns product images > When imageNames is called > it should return image names sorted by uploaded time
  • Unable to run tests locally due to build environment issues (Java version compatibility), relying on CI/CD for verification

Related Issues

Fixes #5013

Notes

This is my contribution as part of EECS 481 (Software Engineering) at University of Michigan.

- Add explicit sortedByDescending in ViewModel to ensure images
  are returned sorted by upload timestamp (newest first)
- Ensures sort order is preserved through Flow transformations
- Fixes openfoodfacts#5013
@sonarqubecloud
Copy link
Copy Markdown

@gabbyemsden gabbyemsden changed the title Fix imageNames sorting to preserve descending timestamp order fix: imageNames sorting to preserve descending timestamp order Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

When imageNames is called > it should return image names sorted by uploaded time() FAILED

1 participant