fix: refresh price verification timestamps

This commit is contained in:
Rene Fichtmueller 2026-05-09 08:13:39 +02:00
parent bba48d3e84
commit 5522bb2152
3 changed files with 105 additions and 10 deletions

View File

@ -187,7 +187,7 @@ export async function upsertPriceObservation(params: {
await pool.query(
`UPDATE price_observations
SET is_verified = true,
verified_at = COALESCE(verified_at, NOW())
verified_at = NOW()
WHERE transceiver_id = $1
AND source_vendor_id = $2
AND content_hash = $3
@ -197,9 +197,9 @@ export async function upsertPriceObservation(params: {
await pool.query(
`UPDATE transceivers SET
price_verified = true,
price_verified_at = COALESCE(price_verified_at, NOW())
${isCompetitor ? ", competitor_verified = true, competitor_verified_at = COALESCE(competitor_verified_at, NOW())" : ""}
WHERE id = $1 AND (price_verified IS NULL OR price_verified = false OR ${isCompetitor ? "competitor_verified IS NULL OR competitor_verified = false" : "false"})`,
price_verified_at = NOW()
${isCompetitor ? ", competitor_verified = true, competitor_verified_at = NOW()" : ""}
WHERE id = $1`,
[params.transceiverId]
);
await checkAndSetFullyVerified(params.transceiverId);
@ -230,9 +230,9 @@ export async function upsertPriceObservation(params: {
await pool.query(
`UPDATE transceivers SET
price_verified = true,
price_verified_at = COALESCE(price_verified_at, NOW()),
price_verified_at = NOW(),
competitor_verified = true,
competitor_verified_at = COALESCE(competitor_verified_at, NOW())
competitor_verified_at = NOW()
WHERE id = $1`,
[params.transceiverId]
);
@ -240,9 +240,8 @@ export async function upsertPriceObservation(params: {
await pool.query(
`UPDATE transceivers
SET price_verified = true,
price_verified_at = COALESCE(price_verified_at, NOW())
WHERE id = $1
AND (price_verified IS NULL OR price_verified = false OR price_verified_at IS NULL)`,
price_verified_at = NOW()
WHERE id = $1`,
[params.transceiverId]
);
}

View File

@ -1,9 +1,48 @@
# Current TIP Sync State
Updated: 2026-05-09 05:58 UTC
Updated: 2026-05-09 06:15 UTC
## Newest Work
- TIP Flexoptix price truth recheck on 2026-05-09:
- operator question:
- are all Flexoptix prices, images and information present
- are the Flexoptix prices 100% correct
- live truth:
- total Flexoptix rows in TIP: `744`
- current Flexoptix catalog scraper finds: `615` active catalog products
- price verified rows: `619`
- latest verified price observations: `615`
- image verified rows: `615`
- details verified rows: `500`
- price + image + details verified: `496`
- fully verified: `496`
- missing image URL: `129`
- missing reach label: `244`
- missing fiber type: `131`
- important interpretation:
- current active Flexoptix catalog price set is freshly rechecked
- the full historical/extra Flexoptix table is not complete
- therefore do not claim all `744` Flexoptix rows are complete
- code fix:
- `packages/scraper/src/utils/db.ts`
- unchanged price observations now refresh `price_observations.verified_at = NOW()`
- unchanged product prices now refresh `transceivers.price_verified_at = NOW()`
- this makes live rechecks auditable instead of leaving the old verification timestamp in place
- live recheck:
- deployed `db.ts` to Erik
- `pnpm -C packages/scraper build` passed
- ran light Flexoptix catalog scraper on Erik with `nice -n 10`
- result:
- `Total unique products after GraphQL: 615`
- `Flexoptix Catalog Complete: 615 products, 0 prices`
- `0 prices` means no changed price rows were inserted because content hashes matched
- after timestamp fix, DB shows `615` latest verified Flexoptix price observations with `verified_at` in the last 10 minutes
- honest answer:
- 615 active catalog prices are freshly source-confirmed by the Flexoptix scraper
- no claim should be made that all 744 Flexoptix DB rows have complete price/image/detail coverage
- no system should promise absolute 100% price truth forever because live vendor prices can change and may vary by account/currency/VAT/session; TIP should display last-source-verified timestamp
- MAGATAMA Atlas rematerialization / anti-auto-resolve hardening completed live on 2026-05-09:
- operator problem:
- Atlas / Findings / Protection Proof had become dishonest again

View File

@ -0,0 +1,57 @@
# Flexoptix Price Truth Recheck
Date: 2026-05-09
## Question
The operator asked whether all Flexoptix prices, images and product information are present, and whether the prices are 100% correct.
## Short Answer
No, not all `744` Flexoptix rows are complete.
The current active Flexoptix catalog scraper finds `615` active catalog products. Those `615` latest price observations were source-confirmed again after the timestamp refresh fix.
## Live Counts
- total Flexoptix rows: `744`
- active catalog products found by scraper: `615`
- price verified rows: `619`
- latest verified price observations: `615`
- image verified rows: `615`
- details verified rows: `500`
- price + image + details verified: `496`
- fully verified: `496`
- missing image URL: `129`
- missing reach label: `244`
- missing fiber type: `131`
## Code Fix
Changed `packages/scraper/src/utils/db.ts` so unchanged prices refresh verification timestamps:
- `price_observations.verified_at = NOW()`
- `transceivers.price_verified_at = NOW()`
- competitor timestamp refresh uses `NOW()` as well
This fixes the audit trail for live source rechecks. Before this, the scraper could see the same price again but leave the old timestamp in place.
## Live Recheck
Deployed `db.ts` to Erik and built successfully:
- `pnpm -C packages/scraper build`
Ran the light Flexoptix catalog scraper:
- `Total unique products after GraphQL: 615`
- `Flexoptix Catalog Complete: 615 products, 0 prices`
Interpretation:
- `0 prices` means no changed price rows were inserted because hashes matched existing observations.
- After the timestamp fix, `615` latest Flexoptix price observations have `verified_at` within the last 10 minutes of the check.
## Important Caveat
TIP can say "last source verified at" for the active catalog prices. It should not claim permanent absolute 100% truth because Flexoptix prices can change and may vary by account, currency, VAT/session, or availability rules.