Skip to content

Commit 7207cbf

Browse files
committed
feat: coalesce scheduledAt for item timestamps
1 parent b97ca2e commit 7207cbf

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

api/resolvers/item.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function commentsOrderByClause (me, models, sort) {
3939
if (sort === 'recent') {
4040
return `ORDER BY ${sharedSorts},
4141
("Item".cost > 0 OR "Item"."weightedVotes" - "Item"."weightedDownVotes" > 0) DESC,
42-
COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC, "Item".id DESC`
42+
COALESCE("Item"."scheduledAt", "Item"."invoicePaidAt", "Item".created_at) DESC, "Item".id DESC`
4343
}
4444

4545
if (sort === 'hot') {
@@ -447,10 +447,10 @@ export default {
447447
typeClause(type),
448448
muteClause(me)
449449
)}
450-
ORDER BY COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC
450+
ORDER BY COALESCE("Item"."scheduledAt", "Item"."invoicePaidAt", "Item".created_at) DESC
451451
OFFSET $2
452452
LIMIT $3`,
453-
orderBy: 'ORDER BY COALESCE("Item"."invoicePaidAt", "Item".created_at) DESC'
453+
orderBy: 'ORDER BY COALESCE("Item"."scheduledAt", "Item"."invoicePaidAt", "Item".created_at) DESC'
454454
}, decodedCursor.time, decodedCursor.offset, limit, ...subArr)
455455
break
456456
case 'top':

components/item-info.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export default function ItemInfo ({
138138
{embellishUser}
139139
</Link>}
140140
<span> </span>
141-
<Link href={`/items/${item.id}`} title={item.invoicePaidAt || item.createdAt} className='text-reset' suppressHydrationWarning>
142-
{timeSince(new Date(item.invoicePaidAt || item.createdAt))}
141+
<Link href={`/items/${item.id}`} title={item.scheduledAt || item.invoicePaidAt || item.createdAt} className='text-reset' suppressHydrationWarning>
142+
{timeSince(new Date(item.scheduledAt || item.invoicePaidAt || item.createdAt))}
143143
</Link>
144144
{item.prior &&
145145
<>

components/item-job.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default function ItemJob ({ item, toc, rank, children, disableRetry, setD
5959
@{item.user.name}<Badges badgeClassName='fill-grey' height={12} width={12} user={item.user} />
6060
</Link>
6161
<span> </span>
62-
<Link href={`/items/${item.id}`} title={item.createdAt} className='text-reset' suppressHydrationWarning>
63-
{timeSince(new Date(item.createdAt))}
62+
<Link href={`/items/${item.id}`} title={item.scheduledAt || item.invoicePaidAt || item.createdAt} className='text-reset' suppressHydrationWarning>
63+
{timeSince(new Date(item.scheduledAt || item.invoicePaidAt || item.createdAt))}
6464
</Link>
6565
</span>
6666
{item.subName &&

fragments/items.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const ITEM_FIELDS = gql`
1919
parentId
2020
createdAt
2121
invoicePaidAt
22+
scheduledAt
2223
deletedAt
2324
title
2425
url

lib/rss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const generateRssItem = (item) => {
3131
<link>${escapeXml(link)}</link>
3232
<comments>${guid}</comments>
3333
<description><![CDATA[<a href="${guid}">Comments</a>]]></description>
34-
<pubDate>${new Date(item.createdAt).toUTCString()}</pubDate>
34+
<pubDate>${new Date(item.scheduledAt || item.invoicePaidAt || item.createdAt).toUTCString()}</pubDate>
3535
${category}
3636
<atom:author><atom:name>${item.user.name}</atom:name></atom:author>
3737
</item>

0 commit comments

Comments
 (0)