feat(MED-131): update analyses sync to medusa store
This commit is contained in:
18
lib/services/sync-entries.service.ts
Normal file
18
lib/services/sync-entries.service.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { format } from 'date-fns';
|
||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||
|
||||
export const getLastCheckedDate = async () => {
|
||||
const { data: lastChecked } = await getSupabaseServerAdminClient()
|
||||
.schema('audit')
|
||||
.from('sync_entries')
|
||||
.select('created_at')
|
||||
.eq('status', 'SUCCESS')
|
||||
.order('created_at')
|
||||
.limit(1);
|
||||
const lastEntry = lastChecked?.[0];
|
||||
const lastCheckedDate = lastEntry
|
||||
? format(lastEntry.created_at, 'yyyy-MM-dd HH:mm:ss')
|
||||
: null;
|
||||
|
||||
return lastCheckedDate;
|
||||
}
|
||||
Reference in New Issue
Block a user