Skip to content

Conversation

@cbullinger
Copy link
Collaborator

Summary

Adds the GET /api/movies/genres endpoint to both Java Spring and Python FastAPI backends to support the genre filter feature added in the JS/Express backend.

Changes

Java Spring Backend

  • Added getDistinctGenres() method to MovieService interface
  • Implemented getDistinctGenres() in MovieServiceImpl using mongoTemplate.findDistinct()
  • Added /genres endpoint to MovieControllerImpl

Python FastAPI Backend

  • Added /genres endpoint to movies.py router using collection.distinct()

Implementation Details

Both implementations:

  • Use MongoDB's distinct() operation to get unique genre values from the genres array field
  • Filter out null/empty values
  • Sort results alphabetically
  • Return a success response with the count of distinct genres

Testing

  • Verified both endpoints return identical results (28 distinct genres)
  • Tested with the frontend genre filter dropdown - works correctly with both backends

Pull Request opened by Augment Code with guidance from the PR author

@cbullinger cbullinger changed the title Add GET /api/movies/genres endpoint to Java Spring and Python FastAPI backends DOCSP-56868: Add GET /api/movies/genres endpoint to Java Spring and Python FastAPI backends Jan 15, 2026
… backends

- Java: Added getDistinctGenres() to MovieService interface and MovieServiceImpl
- Java: Added /genres endpoint to MovieControllerImpl using mongoTemplate.findDistinct()
- Python: Added /genres endpoint to movies.py router using collection.distinct()
- Both implementations filter null/empty values and sort alphabetically
- Returns success response with count of distinct genres
@cbullinger cbullinger force-pushed the docsp-55528-filtering-java-python branch from a9f7ab0 to 3be4fc5 Compare January 15, 2026 14:27
Copy link
Collaborator

@dacharyc dacharyc left a comment

Choose a reason for hiding this comment

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

Overall seems to work fine - both backends are working correctly with the frontend.

Just a small Q about whether we want to add tests for this functionality. (Probably also applies to the Express backend.)

"Demonstrates the distinct() operation. Returns genres sorted alphabetically."
)
@GetMapping("/genres")
public ResponseEntity<SuccessResponse<List<String>>> getDistinctGenres() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add tests for this to the test target? Looks like we have both Controller and Service tests there where we may want to consider adding this.

Search movies using MongoDB Vector Search to enable semantic search capabilities over
the plot field.
- GET /api/movies/genres :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same Q here - since this is a new route, should we add a test for it in the tests dir?

@cbullinger cbullinger changed the base branch from docsp-55528-filtering-js to feature/filtering January 16, 2026 17:43
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.

3 participants