Skip to content

Commit 9ec94dd

Browse files
committed
fix update check
1 parent a2f6ed7 commit 9ec94dd

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

devcon-api/src/services/ai/open-ai/open-ai.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,17 @@ export const destinoApi = (() => {
540540
const eventExists = !!eventRecord
541541

542542
// If exists and updated after last modification, return cached content
543-
if (eventRecord && new Date(eventRecord.updated_at) < new Date(event.LastModifiedDate)) {
544-
return eventRecord.content
543+
if (eventRecord) {
544+
// console.log('record found')
545+
// console.log('updated_at:', eventRecord.updated_at)
546+
// console.log('LastModifiedDate:', event.LastModifiedDate)
547+
// console.log('updated_at date:', new Date(eventRecord.updated_at))
548+
// console.log('LastModifiedDate date:', new Date(event.LastModifiedDate))
549+
// console.log('comparison result:', new Date(eventRecord.updated_at) > new Date(event.LastModifiedDate))
550+
551+
if (new Date(eventRecord.updated_at) > new Date(event.LastModifiedDate)) {
552+
return eventRecord.content
553+
}
545554
}
546555

547556
// Otherwise generate new content
@@ -638,7 +647,7 @@ export const destinoApi = (() => {
638647
}
639648

640649
// Save to Supabase
641-
const result = await supabase.from('destino_events').upsert(upsert)
650+
const result = await supabase.from('destino_events').upsert(upsert, { defaultToNull: false })
642651

643652
return result
644653
},

0 commit comments

Comments
 (0)