mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #3491 from omnivore-app/fix/dont-sync-readingtime-too-soon
Only sync reading times if they are more than a minute old
This commit is contained in:
commit
9102fc9ae4
2 changed files with 14 additions and 1 deletions
|
|
@ -18,4 +18,7 @@ export const appDataSource = new DataSource({
|
|||
logger: new CustomTypeOrmLogger(['query', 'info']),
|
||||
connectTimeoutMS: 40000, // 40 seconds
|
||||
maxQueryExecutionTime: 10000, // 10 seconds
|
||||
extra: {
|
||||
options: process.env.PG_EXTRA_OPTIONS,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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