Page MenuHomePhabricator

Django backend API for Cat-a-lot year filter
Open, Needs TriagePublic

Description

For being able filter fast images based on year when image was taken we need simple API for querying the information. (Note: It would be nice if the data would stored as linked data but in our case it is faster to just create simple API.

Features:

Http parameters:

  • page_ids : list of page_ids of the pages to be inspected (ie. files in Wikimedia Commons). Format is comma separated list.
  • 'start_year' and 'end_year' : return page_ids which year value in database is between start and end year
  • year : return page_ids which 'year' value in database is exactly the year
  • simulated : if TRUE return generated fake values
  • Return values are page_ids which are matched to the query. Format is JSON
  • Support GET and POST requests

Example query:
https://localhost/cat_a_lot_yearfilter?page_ids=123,124,125,126&year=1995&simulated=1
return value: "[ 123, 125 ]"

Database structure
data in the database should be in format

  • page_id : int(10) unsigned
  • year : smallint

Management commands

  • There should be management command for importing the page - year data from file. Data itself is generated in task T390655. Format of the data is tab separated list. List can be huge and gzipped so file should be read line-by-line and stored to database in chunks. If page-year data is reloaded then old data is deleted first.
page_id year
291 1999
292 1935
293 2004

Development
Do a locally working version first. The project should be stored in Github or GitLab so it can be easily deployed to Toolforge. If needed, it can be stored under the https://github.com/Wikimedia-Suomi GitHub account.

Deployment
API will be deployed to Toolforge. Account needs to be registered first as it could take some days to be approved.

Event Timeline

Zache renamed this task from Django API for Cat-a-lot year filter to Django backend API for Cat-a-lot year filter.Apr 1 2025, 7:07 AM
Zache updated the task description. (Show Details)

Hey @Zache I would like to pick up this task if its open to contribute to.

I have added a GitHub repository where I am storing the API solution
https://github.com/Rhytah/YearFilter.git

cc: @Zache