fix auction ranking with query layers
This commit is contained in:
parent
5bd66349c0
commit
fbd746b023
|
@ -323,26 +323,21 @@ export default {
|
||||||
me,
|
me,
|
||||||
models,
|
models,
|
||||||
query: `
|
query: `
|
||||||
SELECT *
|
${SELECT},
|
||||||
FROM (
|
CASE WHEN status = 'ACTIVE' AND "maxBid" > 0
|
||||||
(${SELECT}
|
THEN 0 ELSE 1 END AS group_rank,
|
||||||
|
CASE WHEN status = 'ACTIVE' AND "maxBid" > 0
|
||||||
|
THEN rank() OVER (ORDER BY "maxBid" DESC, created_at ASC)
|
||||||
|
ELSE rank() OVER (ORDER BY created_at DESC) END AS rank
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE "parentId" IS NULL AND created_at <= $1
|
WHERE "parentId" IS NULL AND created_at <= $1
|
||||||
AND "pinId" IS NULL
|
AND "pinId" IS NULL
|
||||||
${subClause(sub, 3)}
|
${subClause(sub, 3)}
|
||||||
AND status = 'ACTIVE' AND "maxBid" > 0
|
AND status IN ('ACTIVE', 'NOSATS')
|
||||||
ORDER BY "maxBid" DESC, created_at ASC)
|
ORDER BY group_rank, rank
|
||||||
UNION ALL
|
|
||||||
(${SELECT}
|
|
||||||
FROM "Item"
|
|
||||||
WHERE "parentId" IS NULL AND created_at <= $1
|
|
||||||
AND "pinId" IS NULL
|
|
||||||
${subClause(sub, 3)}
|
|
||||||
AND ((status = 'ACTIVE' AND "maxBid" = 0) OR status = 'NOSATS')
|
|
||||||
ORDER BY created_at DESC)
|
|
||||||
) a
|
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`
|
LIMIT ${LIMIT}`,
|
||||||
|
orderBy: 'ORDER BY group_rank, rank'
|
||||||
}, decodedCursor.time, decodedCursor.offset, ...subArr)
|
}, decodedCursor.time, decodedCursor.offset, ...subArr)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue