11import path from "path" ;
22import fs from "fs" ;
3- import { INTERVAL , LOCAL_DIR } from "./config" ;
3+ import { INTERVAL , LOCAL_DIR , scheduleUpdate } from "./config" ;
44import { differenceInSeconds } from "date-fns" ;
55
66type Health = {
@@ -11,8 +11,8 @@ type Health = {
1111 date : string ;
1212 } ; // last commit details. read from LOCAL_DIR/.commit file
1313 lastCloned : string ; // read this from LOCAL_DIR/.timestamp file
14- nextClone : string ; // add INTERVAL milliseconds to the timestamp file and create a date object .toISOstring()
15- eta : string ; // calculate the hours:minutes:seconds between current and next time
14+ nextClone ? : string ; // add INTERVAL milliseconds to the timestamp file and create a date object .toISOstring()
15+ eta ? : string ; // calculate the hours:minutes:seconds between current and next time
1616} ;
1717
1818export async function queryCache ( localDir : string , id : string , res : any ) {
@@ -71,11 +71,16 @@ export async function cacheHealth(res: any) {
7171 2 ,
7272 "0"
7373 ) } m:${ String ( seconds ) . padStart ( 2 , "0" ) } s`;
74+ const nextCloneAndEta = scheduleUpdate
75+ ? {
76+ nextClone : nextCloneDate . toISOString ( ) ,
77+ eta : eta ,
78+ }
79+ : { } ;
7480 const healthStatus : Health = {
7581 lastCommit : JSON . parse ( lastCommitDetails ) as any ,
7682 lastCloned : lastClonedDate . toISOString ( ) ,
77- nextClone : nextCloneDate . toISOString ( ) ,
78- eta : eta ,
83+ ...nextCloneAndEta ,
7984 } ;
8085 res . status ( 200 ) . json ( healthStatus ) ;
8186}
0 commit comments