Use Denver local time for scrape dates instead of UTC
Some checks failed
CI/CD Pipeline - Apartment API / Scan Dependencies (push) Successful in 18s
CI/CD Pipeline - Apartment API / Lint & Test (push) Successful in 1m27s
CI/CD Pipeline - Apartment API / Send Webhook Notification (push) Has been skipped
CI/CD Pipeline - Apartment API / Build & Push Image (push) Successful in 3m17s
CI/CD Pipeline - Apartment API / Deploy to Production (push) Failing after 27s
Some checks failed
CI/CD Pipeline - Apartment API / Scan Dependencies (push) Successful in 18s
CI/CD Pipeline - Apartment API / Lint & Test (push) Successful in 1m27s
CI/CD Pipeline - Apartment API / Send Webhook Notification (push) Has been skipped
CI/CD Pipeline - Apartment API / Build & Push Image (push) Successful in 3m17s
CI/CD Pipeline - Apartment API / Deploy to Production (push) Failing after 27s
Change date helper functions to use toLocaleDateString with the configured SCRAPER_TIMEZONE (America/Denver) so that scrape date records (date_checked, daily summaries) reflect local time. A late-night manual scrape and early-morning automated scrape will no longer both report as the same UTC day. ISO timestamps for last_scraped, first_seen, startedAt etc. remain in UTC as they represent precise moments.
This commit is contained in:
@ -626,11 +626,11 @@ async function updateDailySummary(db, summaryData, logger) {
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* Get today's date in YYYY-MM-DD format (UTC).
|
||||
* Get today's date in YYYY-MM-DD format using the configured timezone.
|
||||
* @returns {string} Today's date string
|
||||
*/
|
||||
function getTodayUTC() {
|
||||
return new Date().toISOString().split('T')[0];
|
||||
function getToday() {
|
||||
return new Date().toLocaleDateString('en-CA', { timeZone: config.SCRAPER_TIMEZONE });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -820,7 +820,7 @@ async function runScrape(db, options = {}) {
|
||||
result.unitsProcessed = units.length;
|
||||
|
||||
// Step 4: Database operations
|
||||
const today = getTodayUTC();
|
||||
const today = getToday();
|
||||
|
||||
// Get yesterday's unit codes for comparison
|
||||
const yesterdayUnits = await getYesterdayUnitCodes(db, today);
|
||||
@ -904,7 +904,7 @@ module.exports = {
|
||||
recordScraperRun,
|
||||
createScraperIndexes,
|
||||
// Export helpers for testing
|
||||
getTodayUTC,
|
||||
getToday,
|
||||
getYesterdayUnitCodes,
|
||||
getYesterday,
|
||||
parseInteger,
|
||||
|
||||
Reference in New Issue
Block a user