diff --git a/api/resolvers/item.js b/api/resolvers/item.js index cf3d60fcf..5f0c0eaf7 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -247,7 +247,7 @@ export const whereClause = (...clauses) => { } function whenClause (when, table) { - return `"${table}".created_at <= $2 and "${table}".created_at >= $1` + return `COALESCE("${table}"."invoicePaidAt", "${table}".created_at) <= $2 and COALESCE("${table}"."invoicePaidAt", "${table}".created_at) >= $1` } export const activeOrMine = (me) => { @@ -433,7 +433,7 @@ export default { ${SELECT} ${relationClause(type)} ${whereClause( - '"Item".created_at <= $1', + 'COALESCE("Item"."invoicePaidAt", "Item".created_at) <= $1', '"Item"."deletedAt" IS NULL', subClause(sub, 4, subClauseTable(type), me, showNsfw), activeOrMine(me),