Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix script that refreshes pageviews #3233

Merged
merged 3 commits into from
Feb 27, 2024
Merged

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Feb 22, 2024

  • The script that runs on make refresh.pageviews currently doesn't work. It incorrectly filters out all rows, and then inserts 0 rows into the database.
  • This statement threw out all entries (maybe because additional columns were recently added to the Datsette table?):
    const onlyValidRows = [...parsedData.data].filter(
    (row) => Object.keys(row as any).length === 5
    ) as any[]
  • To make this a bit more robust, I grab all valid pageview fields from each row of the downloaded data. A row is then declared "valid" if it has a day and a URL
    • Note that we're also removing rows where the URL contains an emoji since MySQL couldn't insert those. We currently have one single entry where the URL contains an emoji (Datasette)

Also, knex gives me the following warning when running this script:

Screenshot 2024-02-22 at 16 44 42

Is this something we should care about?

@sophiamersmann sophiamersmann changed the title 🐛 fix script to refresh pageviews 🐛 fix script that refreshes pageviews Feb 22, 2024
Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for fixing this! The complaint was because TRUNCATE is a DDL statement (i.e. in the category of schema modifying operations) and they have their own implicit transaction so should not be run in a data modifying transaction. Good to go now!

@sophiamersmann sophiamersmann merged commit 5628d2e into master Feb 27, 2024
14 of 17 checks passed
@sophiamersmann sophiamersmann deleted the fix-pageview-refresh branch February 27, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants