Migrate gallery.go and validations.go to goqu
CrescentKohana opened this issue · 1 comments
CrescentKohana commented
This one might be the most challenging part of the goqu rework.
GetGalleries
function is very elaborate and prone to bugs if not converted carefully.UpdateGallery
can probably be refactored to be much shorter and better written overall. The Jet library made it hard to do partial updates.NeedsUpdate
isn't used anywhere currently and can be pretty much ignored
CrescentKohana commented
Raw SQL by Jet can be seen with println(stmt.DebugSql())
Example for /galleries?tag=female:swimsuit&tag=female:bikini&sortby=original
:
SELECT galleries.`gallery.uuid` AS "gallery.uuid",
galleries.`gallery.library_id` AS "gallery.library_id",
galleries.`gallery.archive_path` AS "gallery.archive_path",
galleries.`gallery.title` AS "gallery.title",
galleries.`gallery.title_native` AS "gallery.title_native",
galleries.`gallery.title_translated` AS "gallery.title_translated",
galleries.`gallery.category` AS "gallery.category",
galleries.`gallery.series` AS "gallery.series",
galleries.`gallery.released` AS "gallery.released",
galleries.`gallery.language` AS "gallery.language",
galleries.`gallery.translated` AS "gallery.translated",
galleries.`gallery.nsfw` AS "gallery.nsfw",
galleries.`gallery.hidden` AS "gallery.hidden",
galleries.`gallery.image_count` AS "gallery.image_count",
galleries.`gallery.archive_size` AS "gallery.archive_size",
galleries.`gallery.archive_hash` AS "gallery.archive_hash",
galleries.`gallery.thumbnail` AS "gallery.thumbnail",
galleries.`gallery.created_at` AS "gallery.created_at",
galleries.`gallery.updated_at` AS "gallery.updated_at",
tag.namespace AS "tag.namespace",
tag.name AS "tag.name",
reference.exh_gid AS "reference.exh_gid",
reference.exh_token AS "reference.exh_token",
reference.urls AS "reference.urls"
FROM (
SELECT gallery.uuid AS "gallery.uuid",
gallery.library_id AS "gallery.library_id",
gallery.archive_path AS "gallery.archive_path",
gallery.title AS "gallery.title",
gallery.title_native AS "gallery.title_native",
gallery.title_translated AS "gallery.title_translated",
gallery.category AS "gallery.category",
gallery.series AS "gallery.series",
gallery.released AS "gallery.released",
gallery.language AS "gallery.language",
gallery.translated AS "gallery.translated",
gallery.nsfw AS "gallery.nsfw",
gallery.hidden AS "gallery.hidden",
gallery.image_count AS "gallery.image_count",
gallery.archive_size AS "gallery.archive_size",
gallery.archive_hash AS "gallery.archive_hash",
gallery.thumbnail AS "gallery.thumbnail",
gallery.created_at AS "gallery.created_at",
gallery.updated_at AS "gallery.updated_at"
FROM gallery
WHERE TRUE AND (EXISTS (
SELECT NULL
FROM gallery_tag AS gt
INNER JOIN tag AS t ON (t.id = gt.tag_id)
WHERE ((t.namespace IN ('female', 'female')) AND (t.name IN ('swimsuit', 'bikini'))) AND (gt.gallery_uuid = gallery.uuid)
GROUP BY gt.gallery_uuid
HAVING COUNT(t.name) = 2
))
ORDER BY gallery.title ASC
LIMIT 50
OFFSET 0
) AS galleries
LEFT JOIN gallery_tag ON (gallery_tag.gallery_uuid = galleries.`gallery.uuid`)
LEFT JOIN tag ON (tag.id = gallery_tag.tag_id)
LEFT JOIN reference ON (reference.gallery_uuid = galleries.`gallery.uuid`);