Skip to content

Commit

Permalink
fix(api/database): return proper condition to determine when to updat…
Browse files Browse the repository at this point in the history
…e database
  • Loading branch information
GervinFung committed Jun 25, 2024
1 parent 246916b commit 98141b9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions apps/web/src/api/database/persistence/template-batch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,12 @@ class TemplateBatchPersistence {
return result.match({
failed,
succeed: async (latestTimeCommitted) => {
console.log({
latestTimeCommitted,
});
return this.findLatestTimeCommitted().then(
(result) => {
return result.match({
failed,
succeed: async (latestTime) => {
return isTimeEqual(
return !isTimeEqual(
latestTimeCommitted,
latestTime.latestCommittedTime
);
Expand Down Expand Up @@ -125,9 +122,7 @@ class TemplateBatchPersistence {
return this.shouldUpdate().then((result) => {
return result.flatMap(async (shouldUpdate) => {
if (isFalse(shouldUpdate)) {
return DatabaseOperation.failed(
new Error('No need to update')
);
return this.findLatestTimeCommitted();
}

return await this.insertion()
Expand Down

0 comments on commit 98141b9

Please sign in to comment.