almost ready

This commit is contained in:
bob
2026-06-01 10:52:06 -05:00
parent 8b0eb0db78
commit 763305ca89
94 changed files with 8766 additions and 2674 deletions

View File

@@ -20,12 +20,12 @@
SET search_path = skintracker;
INSERT INTO skin_conditions (skin_id, condition, min_float, max_float)
INSERT INTO skin_conditions (skin_id, condition, float_min, float_max)
SELECT
s.id,
t.name,
GREATEST(s.float_min, t.lo) AS min_float, -- clamp the tier to the skin's range
LEAST(s.float_max, t.hi) AS max_float
GREATEST(s.float_min, t.lo) AS float_min, -- clamp the tier to the skin's range
LEAST(s.float_max, t.hi) AS float_max
FROM skins s
CROSS JOIN (VALUES
('Factory New', 0.00, 0.07),
@@ -51,9 +51,9 @@ ORDER BY s.id, t.lo;
-- Sanity checks (optional)
-- ------------------------------------------------------------
-- Rows per condition:
-- SELECT condition, count(*) FROM skin_conditions GROUP BY condition ORDER BY min(min_float);
-- SELECT condition, count(*) FROM skin_conditions GROUP BY condition ORDER BY min(float_min);
--
-- Spot-check a capped skin (e.g. an Asiimov) shows clamped FT bounds:
-- SELECT s.name, sc.condition, sc.min_float, sc.max_float
-- SELECT s.name, sc.condition, sc.float_min, sc.float_max
-- FROM skin_conditions sc JOIN skins s ON s.id = sc.skin_id
-- WHERE s.name ILIKE 'Asiimov' ORDER BY sc.min_float;
-- WHERE s.name ILIKE 'Asiimov' ORDER BY sc.float_min;

View File

@@ -1,44 +1,18 @@
-- ============================================================
-- CS2 Skin Tracker — backfill skin_conditions.listings_swept_at
-- Run against the skintracker database as the app role, ONCE,
-- after the AddSkinConditionListingsSweptAt migration is applied
-- and 05_fill_skin_conditions.sql has populated the wear bands.
-- Idempotent: re-running only touches still-null bands.
--
-- Why: the catalogue sweep used to page each skin to completion
-- as a single unit, so a non-null skins.listings_swept_at means
-- EVERY wear of that skin was covered at that time. The sweep now
-- checkpoints per wear band (skin_conditions.listings_swept_at).
-- Without this backfill, every band of an already-swept skin would
-- look never-swept and jump to the front of the queue, needlessly
-- re-sweeping skins that are already current. Inheriting the skin's
-- timestamp marks those bands as covered so the sweep moves on.
-- SUPERSEDED — DO NOT RUN.
--
-- Only fills bands that are still null, so bands already swept under
-- the new per-band logic keep their (newer) timestamp.
-- The single shared `listings_swept_at` columns on `skins` and
-- `skin_conditions` were replaced by per-site checkpoint tables
-- (`skin_sweeps` / `skin_condition_sweeps`, keyed by (entity, source))
-- in the AddPerSiteSweepCheckpoints migration. Each site now tracks its
-- own "last swept" under its own `source`, so a band swept on CSFloat is
-- still never-swept on cs.money.
--
-- The columns this script updated no longer exist, so running it now
-- would error. We intentionally did NOT migrate the old values into the
-- new tables: both sites simply cold-sweep the catalogue once and the
-- never-swept-first ordering refills the checkpoints. This file is kept
-- only so the db/ script numbering stays stable.
-- ============================================================
SET search_path = skintracker;
UPDATE skin_conditions sc
SET listings_swept_at = s.listings_swept_at
FROM skins s
WHERE sc.skin_id = s.id
AND s.listings_swept_at IS NOT NULL -- skin was fully swept under the old per-skin logic
AND sc.listings_swept_at IS NULL; -- don't overwrite bands already swept per-band
-- ------------------------------------------------------------
-- Sanity checks (optional)
-- ------------------------------------------------------------
-- Bands backfilled vs still never-swept:
-- SELECT
-- count(*) FILTER (WHERE listings_swept_at IS NOT NULL) AS swept,
-- count(*) FILTER (WHERE listings_swept_at IS NULL) AS never_swept
-- FROM skin_conditions;
--
-- A previously-swept skin should now have all its bands stamped:
-- SELECT s.name, sc.condition, sc.listings_swept_at
-- FROM skin_conditions sc JOIN skins s ON s.id = sc.skin_id
-- WHERE s.listings_swept_at IS NOT NULL
-- ORDER BY s.name, sc.min_float
-- LIMIT 20;