feat:
This commit is contained in:
parent
b400f22844
commit
cbbc2c179d
3 changed files with 74 additions and 66 deletions
|
|
@ -138,7 +138,7 @@ LEFT JOIN tags as g ON (tt.tag_id = g.id)
|
|||
LEFT JOIN studios as s ON (t.studio_id = s.id)
|
||||
LEFT JOIN images as si ON (s.illust_id = si.id)
|
||||
|
||||
WHERE id = $1::bigint
|
||||
WHERE t.id = $1::bigint
|
||||
GROUP BY
|
||||
t.id, i.id, s.id, si.id
|
||||
`
|
||||
|
|
@ -428,10 +428,16 @@ WHERE
|
|||
END
|
||||
)
|
||||
|
||||
AND (t.title_status::text IN ($7::text, $8::text, $9::text))
|
||||
AND ($10::float IS NULL OR t.rating >= $10::float)
|
||||
AND ($11::int IS NULL OR t.release_year = $11::int)
|
||||
AND ($12::release_season_t IS NULL OR t.release_season = $12::release_season_t)
|
||||
AND (
|
||||
-- Если массив пуст (NULL или []) — не фильтруем
|
||||
cardinality($7::text[]) = 0
|
||||
OR
|
||||
-- Иначе: статус есть в списке
|
||||
t.title_status = ANY($7::text[])
|
||||
)
|
||||
AND ($8::float IS NULL OR t.rating >= $8::float)
|
||||
AND ($9::int IS NULL OR t.release_year = $9::int)
|
||||
AND ($10::release_season_t IS NULL OR t.release_season = $10::release_season_t)
|
||||
|
||||
GROUP BY
|
||||
t.id, i.id, s.id, si.id
|
||||
|
|
@ -454,7 +460,7 @@ ORDER BY
|
|||
|
||||
CASE WHEN $2::text <> 'id' THEN t.id END ASC
|
||||
|
||||
LIMIT COALESCE($13::int, 100)
|
||||
LIMIT COALESCE($11::int, 100)
|
||||
`
|
||||
|
||||
type SearchTitlesParams struct {
|
||||
|
|
@ -464,9 +470,7 @@ type SearchTitlesParams struct {
|
|||
CursorID *int64 `json:"cursor_id"`
|
||||
CursorRating *float64 `json:"cursor_rating"`
|
||||
Word *string `json:"word"`
|
||||
Ongoing string `json:"ongoing"`
|
||||
Finished string `json:"finished"`
|
||||
Planned string `json:"planned"`
|
||||
TitleStatuses []string `json:"title_statuses"`
|
||||
Rating *float64 `json:"rating"`
|
||||
ReleaseYear *int32 `json:"release_year"`
|
||||
ReleaseSeason *ReleaseSeasonT `json:"release_season"`
|
||||
|
|
@ -505,9 +509,7 @@ func (q *Queries) SearchTitles(ctx context.Context, arg SearchTitlesParams) ([]S
|
|||
arg.CursorID,
|
||||
arg.CursorRating,
|
||||
arg.Word,
|
||||
arg.Ongoing,
|
||||
arg.Finished,
|
||||
arg.Planned,
|
||||
arg.TitleStatuses,
|
||||
arg.Rating,
|
||||
arg.ReleaseYear,
|
||||
arg.ReleaseSeason,
|
||||
|
|
@ -564,7 +566,7 @@ SELECT
|
|||
u.ctime as user_ctime,
|
||||
i.storage_type::text as title_storage_type,
|
||||
i.image_path as title_image_path,
|
||||
jsonb_agg_strict(g.tag_name)'[]'::jsonb as tag_names,
|
||||
jsonb_agg(g.tag_name)'[]'::jsonb as tag_names,
|
||||
s.studio_name as studio_name,
|
||||
s.illust_id as studio_illust_id,
|
||||
s.studio_desc as studio_desc,
|
||||
|
|
@ -718,7 +720,7 @@ type SearchUserTitlesRow struct {
|
|||
UserCtime pgtype.Timestamptz `json:"user_ctime"`
|
||||
TitleStorageType string `json:"title_storage_type"`
|
||||
TitleImagePath *string `json:"title_image_path"`
|
||||
TagNames []byte `json:"tag_names"`
|
||||
TagNames json.RawMessage `json:"tag_names"`
|
||||
StudioName *string `json:"studio_name"`
|
||||
StudioIllustID *int64 `json:"studio_illust_id"`
|
||||
StudioDesc *string `json:"studio_desc"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue