icosa-foundation / icosa-gallery

Icosa Gallery is a 3D model hosting solution, intended as a replacement for Google's Poly
https://icosa.gallery
Apache License 2.0
8 stars 0 forks source link

New "Liked Assets" API endpoint #15

Closed andybak closed 2 months ago

andybak commented 3 months ago

Example query:

/users/me/likedassets?format=TILT&orderBy=LIKED_TIME&pageSize=20

andybak commented 3 months ago

OK. This is a bit tricky. This endpoint is used by the Sketchbook panel. It expects to be able to load a .tilt file.

So we need to have some way to filter likes by whether they have a .tilt or not

i.e. at least one item in the "formats" array has "format" set to "TILT"

Formats is currently just a text field. We could switch to a JSON field type? (EDIT - it already IS a JSON field. My bad...) Or add a new bool field and pre-process all existing files.

A JSON field would be more useful generally but if we want future sqlite support we'll need to check if Django and sqlite can do what we need:

https://docs.djangoproject.com/en/5.0/ref/databases/#enabling-json1-extension-on-sqlite

andybak commented 3 months ago

And even if we do want a JSON field - it might be worth also having a boolean for performance reasons.

andybak commented 3 months ago

According to at least one place in the FastAPI code "assets" is a JSONB field:

sqlalchemy.Column("formats", sqlalchemy.dialects.postgresql.JSONB)

(from database_schema.py)

mikeskydev commented 3 months ago

Yep, formats is a JSON field

jamesrampton commented 3 months ago

I think this is done. @andybak do you agree?