Skip to content

Commit

Permalink
Avoid fetching all entities after creating new one
Browse files Browse the repository at this point in the history
For #315.
Whenever a new entity was created, `oldestDate` parameter
during `remoteSync` was sent as NULL, thus forcing fetching
ALL entities again, and leading to sync problems.
Solution is sending the `oldestDate` which is neither invalid
nor NULL.
  • Loading branch information
lmatayoshi committed Jun 19, 2020
1 parent 1bc2e3b commit 127cad9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/actions/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export const remoteSync = (url, user, entityName, mapper) => async () => {
const initializedDb = await db.initializeForUser(user);
const entity = initializedDb[entityName];
const oldestEntity = await entity.findOne({
where: initializedDb.sequelize.literal("lastSyncAt IS NOT 'Invalid date'"),
where: initializedDb.sequelize.literal(
"lastSyncAt IS NOT 'Invalid date' AND lastSyncAt is NOT NULL"
),
order: [['lastSyncAt', 'ASC']]
});
const newestRemoteIdEntity = await entity.findOne({
Expand Down

0 comments on commit 127cad9

Please sign in to comment.