Skip to content

Conversation

Copy link

Copilot AI commented Oct 20, 2025

Overview

This PR implements a feedback mechanism for similar image search results, allowing authenticated users to provide simple thumbs up/down ratings on similar image recommendations. The feedback is stored for administrator auditing to help improve the similarity algorithm over time.

Problem

The ISIC Archive uses image embeddings and vector similarity to recommend similar images to users. However, there was no way to collect user feedback on the quality of these recommendations, making it difficult for administrators to:

  • Identify cases where the similarity algorithm produces poor results
  • Understand which image pairs users find truly similar
  • Collect data to improve the similarity algorithm

Solution

Added a complete feedback system with minimal changes to the existing codebase:

Database Model

Created SimilarImageFeedback model with:

  • Source image and similar image references
  • User attribution
  • Feedback type (thumbs up/down)
  • Unique constraint to prevent duplicate feedback from the same user
  • Automatic timestamps for tracking

API Endpoint

Implemented POST /api/v2/images/{isic_id}/similar-feedback/ that:

  • Requires authentication (returns 401 for unauthenticated users)
  • Validates feedback values (only "up" or "down" accepted)
  • Uses update_or_create to allow users to change their feedback
  • Checks permissions to ensure users can only rate images they can view

User Interface

Enhanced the similar images tab with:

  • Thumbs up 👍 and thumbs down 👎 buttons next to each similar image
  • Only visible to authenticated users
  • Visual feedback with color changes (green for up, red for down)
  • AJAX submission without page reload
  • Error handling with user-friendly messages

Admin Interface

Added Django admin page for staff to:

  • View all feedback records in a searchable, filterable table
  • Filter by feedback type and date
  • Search by username or image ID
  • Click image links to view them in context
  • Export feedback data for analysis

Security

All security requirements have been met:

  • ✅ CodeQL scan: 0 alerts
  • ✅ Authentication required for feedback submission
  • ✅ CSRF protection on all POST requests
  • ✅ Input validation for feedback values
  • ✅ Permission checks for image access
  • ✅ No public display of feedback data (admin-only access)

Testing

Comprehensive test suite with 9 tests covering:

  • Authentication requirements
  • Valid feedback submission (thumbs up/down)
  • Feedback updates and duplicate handling
  • Invalid input rejection
  • 404 handling for non-existent images
  • Database constraint enforcement

Files Changed

  • Models: Added SimilarImageFeedback model and migration
  • API: Added feedback submission endpoint
  • Admin: Added feedback audit interface
  • Templates: Created feedback UI components
  • Tests: Added comprehensive test coverage

All changes are minimal and surgical, with no modifications to unrelated functionality. The feature integrates seamlessly with existing code patterns and follows Django best practices.

Usage

For users: Navigate to any image detail page, click the "Similar Images" tab, and rate images with thumbs up/down buttons.

For administrators: Access /admin/core/similarimagefeedback/ to view, filter, and analyze feedback records.

Original prompt

create a new feature that allows users of similar image search to provide feedback through a very simple thumbs up thumbs down. it should only be allowed for logged in users. there shouldn't be any display of the results anywhere for the current moment. the purpose of this is for administrators to be able to audit which images have good or bad similarity search results.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@danlamanna danlamanna force-pushed the copilot/add-image-search-feedback branch from 391b9dd to 87f5b03 Compare October 20, 2025 19:20
Copilot AI changed the title [WIP] Add feedback feature for similar image search Add user feedback mechanism for similar image search results Oct 20, 2025
Copilot AI requested a review from danlamanna October 20, 2025 19:31
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