Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rleed committed Oct 18, 2023
1 parent 66b14b2 commit 37a2317
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 8 additions & 4 deletions api/resolvers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { notifyItemParents, notifyUserSubscribers, notifyZapped } from '../../li
import { createHmac } from './wallet'
import { settleHodlInvoice } from 'ln-service'
import { initDateRule } from '../../lib/timedate-scraper'
<<<<<<< HEAD
import { moreThanOneYearAgo } from '../../lib/time'
=======
import { datePivot } from '../../lib/time'
import { notifyItemParents, notifyUserSubscribers, notifyZapped } from '../../lib/push-notifications'
>>>>>>> 7be35e0 (address review comments)

export async function commentFilterClause (me, models) {
let clause = ` AND ("Item"."weightedVotes" - "Item"."weightedDownVotes" > -${ITEM_FILTER_THRESHOLD}`
Expand Down Expand Up @@ -489,12 +494,11 @@ export default {
const doc = domino.createWindow(html).document
initDateRule()
const metadata = getMetadata(doc, url, { title: metadataRuleSets.title, publicationDate: metadataRuleSets.publicationDate })
const dateHint = ` (${metadata.publicationDate.getFullYear()})`
const dateHint = ` (${metadata.publicationDate?.getFullYear()})`
const moreThanOneYearAgo = metadata.publicationDate && metadata.publicationDate < datePivot(new Date(), { years: -1 })

res.title = metadata?.title
if (moreThanOneYearAgo(metadata.publicationDate)) {
res.title += dateHint
}
if (moreThanOneYearAgo) res.title += dateHint
} catch { }

try {
Expand Down
4 changes: 0 additions & 4 deletions lib/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,3 @@ export function timeLeft (timeStamp) {
}

export const sleep = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms))

export function moreThanOneYearAgo (date) {
return date < datePivot(new Date(), { years: -1 })
}

0 comments on commit 37a2317

Please sign in to comment.