Update syncedAt after syncing
This commit is contained in:
@ -127,10 +127,9 @@ export function integrationsServiceRouter() {
|
||||
return
|
||||
}
|
||||
}
|
||||
// update integration syncedAt if successful
|
||||
// delete task name if completed
|
||||
await getRepository(Integration).update(integration.id, {
|
||||
taskName: null,
|
||||
syncedAt: new Date(),
|
||||
})
|
||||
} else {
|
||||
logger.info('unknown action', { action })
|
||||
|
||||
@ -5,6 +5,7 @@ import { wait } from '../utils/helpers'
|
||||
import { Page } from '../elastic/types'
|
||||
import { getHighlightLocation, getHighlightUrl } from './highlights'
|
||||
import { Integration } from '../entity/integration'
|
||||
import { getRepository } from '../entity/utils'
|
||||
|
||||
interface ReadwiseHighlight {
|
||||
// The highlight text, (technically the only field required in a highlight object)
|
||||
@ -98,6 +99,13 @@ export const syncWithIntegration = async (
|
||||
default:
|
||||
return false
|
||||
}
|
||||
// update integration syncedAt if successful
|
||||
if (result) {
|
||||
console.log('updating integration syncedAt')
|
||||
await getRepository(Integration).update(integration.id, {
|
||||
syncedAt: new Date(),
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ describe('Integrations routers', () => {
|
||||
})
|
||||
|
||||
context('when action is sync_all', () => {
|
||||
before(() => {
|
||||
before(async () => {
|
||||
action = 'sync_all'
|
||||
data = {
|
||||
message: {
|
||||
@ -306,6 +306,10 @@ describe('Integrations routers', () => {
|
||||
})
|
||||
.post('/highlights', highlightsData)
|
||||
.reply(200)
|
||||
await getRepository(Integration).update(integration.id, {
|
||||
syncedAt: null,
|
||||
taskName: 'some task name',
|
||||
})
|
||||
})
|
||||
|
||||
it('returns 200 with OK', async () => {
|
||||
|
||||
Reference in New Issue
Block a user