diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 8a02cf92..ae12bbaf 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -75,28 +75,6 @@ export async function getItem (parent, { id }, { me, models }) { return item } -function whenClause (when, type) { - let interval = ` AND "${type === 'bookmarks' ? 'Bookmark' : 'Item'}".created_at >= $1 - INTERVAL ` - switch (when) { - case 'forever': - interval = '' - break - case 'week': - interval += "'7 days'" - break - case 'month': - interval += "'1 month'" - break - case 'year': - interval += "'1 year'" - break - default: - interval += "'1 day'" - break - } - return interval -} - const orderByClause = async (by, me, models, type) => { switch (by) { case 'comments': @@ -207,6 +185,28 @@ export const whereClause = (...clauses) => { return clause ? ` WHERE ${clause} ` : '' } +function whenClause (when, type) { + let interval = `"${type === 'bookmarks' ? 'Bookmark' : 'Item'}".created_at >= $1 - INTERVAL ` + switch (when) { + case 'forever': + interval = '' + break + case 'week': + interval += "'7 days'" + break + case 'month': + interval += "'1 month'" + break + case 'year': + interval += "'1 year'" + break + default: + interval += "'1 day'" + break + } + return interval +} + const activeOrMine = (me) => { return me ? `("Item".status <> 'STOPPED' OR "Item"."userId" = ${me.id})` : '"Item".status <> \'STOPPED\'' }