mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Only sync reading times if they are more than a minute old
this should hopefully reduce contention with other rules running
This commit is contained in:
parent
2c037d6a8a
commit
9cc046e3a2
1 changed files with 11 additions and 1 deletions
|
|
@ -25,6 +25,14 @@ async function* getSyncUpdatesIterator(redis: Redis) {
|
|||
return
|
||||
}
|
||||
|
||||
const isMoreThan60SecondsOld = (iso8601String: string): boolean => {
|
||||
const currentTime = new Date()
|
||||
const parsedDate = new Date(iso8601String)
|
||||
const timeDifferenceInSeconds =
|
||||
(currentTime.getTime() - parsedDate.getTime()) / 1000
|
||||
return timeDifferenceInSeconds > 60
|
||||
}
|
||||
|
||||
const syncReadPosition = async (cacheKey: string) => {
|
||||
const components = componentsForCachedReadingPositionKey(cacheKey)
|
||||
const positions = components
|
||||
|
|
@ -37,7 +45,9 @@ const syncReadPosition = async (cacheKey: string) => {
|
|||
components &&
|
||||
positions &&
|
||||
positions.positionItems &&
|
||||
positions.positionItems.length > 0
|
||||
positions.positionItems.length > 0 &&
|
||||
positions.positionItems[0].updatedAt &&
|
||||
isMoreThan60SecondsOld(positions.positionItems[0].updatedAt)
|
||||
) {
|
||||
const position = reduceCachedReadingPositionMembers(
|
||||
components.uid,
|
||||
|
|
|
|||
Loading…
Reference in a new issue