SCRAPE-31: Add scraper indexes and validation collections #30

Merged
stephen merged 2 commits from scraper/indexes into dev 2026-02-07 16:50:51 -07:00
Owner

Added createScraperIndexes() for scraper_runs collection with compound index on status+startedAt and descending index on startedAt. Changed default collection names from production (units_migration_test, unit_prices_migration_test) to validation (units_scraper, unit_prices_scraper) for parallel validation. Updated all scraper test files.

Added createScraperIndexes() for scraper_runs collection with compound index on status+startedAt and descending index on startedAt. Changed default collection names from production (units_migration_test, unit_prices_migration_test) to validation (units_scraper, unit_prices_scraper) for parallel validation. Updated all scraper test files.
stephen added 1 commit 2026-02-07 12:05:39 -07:00
Add scraper indexes and switch to validation collection names
All checks were successful
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (pull_request) Successful in 43s
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 2s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped
2e3ef0580c
Add createScraperIndexes() to create indexes on the scraper_runs
collection: a compound index on status+startedAt for active job queries
and a descending index on startedAt for recent run lookups.

Change default collection names from production tables
(units_migration_test, unit_prices_migration_test) to dedicated
validation collections (units_scraper, unit_prices_scraper). This
enables the Node.js scraper to run in parallel with the existing Python
scraper during validation without interfering with production data.

Update all scraper test files to reference the new default collection
names.
Author
Owner

❌ Changes Requested

The createScraperIndexes function contains a console.log statement in production code. It should use the logger pattern consistent with the rest of the service.

Issues:

services/scraperService.js:762
Remove console.log('Scraper indexes created successfully'). Production code must not use console.log. Either accept a logger parameter (consistent with all other functions in this service like recordScraperRun(db, runData, logger)) and call logger.info(...), or remove the log statement entirely. The function signature should be createScraperIndexes(db, logger) to match the existing pattern.

## ❌ Changes Requested The `createScraperIndexes` function contains a `console.log` statement in production code. It should use the logger pattern consistent with the rest of the service. ### Issues: **services/scraperService.js:762** Remove `console.log('Scraper indexes created successfully')`. Production code must not use `console.log`. Either accept a `logger` parameter (consistent with all other functions in this service like `recordScraperRun(db, runData, logger)`) and call `logger.info(...)`, or remove the log statement entirely. The function signature should be `createScraperIndexes(db, logger)` to match the existing pattern.
stephen added 1 commit 2026-02-07 16:49:24 -07:00
Use logger parameter instead of console.log in createScraperIndexes
All checks were successful
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (pull_request) Successful in 44s
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 2s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped
fe24154518
Accept logger as second parameter to match the pattern used by all other
functions in scraperService.js (recordScraperRun, upsertUnits, etc.).
Replaces console.log with logger.info for production code consistency.
stephen merged commit 4ca202068f into dev 2026-02-07 16:50:51 -07:00
stephen deleted branch scraper/indexes 2026-02-07 16:50:51 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stephen/apartment-dashboard-api#30
No description provided.