Skip to content

Commit

Permalink
Merge pull request #39 from datamade/bugfix/36-scraped-at
Browse files Browse the repository at this point in the history
Fix scraped_at update during rescrape
  • Loading branch information
antidipyramid authored Mar 15, 2024
2 parents 46f2d46 + 10b4eee commit 60570d2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/update_rescraped_cases.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,19 @@ SELECT * FROM plaintiff
WHERE
case_number IN (SELECT * FROM updated_case);

CREATE TEMPORARY TABLE unchanged_case(num text);
INSERT INTO
unchanged_case
SELECT
a.case_number
FROM
court_case as a
LEFT JOIN cases.court_case as b ON a.case_number = b.case_number
WHERE
a.hash = b.hash;

-- For cases that haven't changed, just update their scraped_at field
UPDATE cases.court_case
SET scraped_at = CURRENT_TIMESTAMP
WHERE
case_number NOT IN (SELECT * FROM updated_case);
case_number IN (SELECT * FROM unchanged_case);

0 comments on commit 60570d2

Please sign in to comment.