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

chore: add migration for traffic data collection #6171

Merged
merged 4 commits into from
Feb 9, 2024

Conversation

daveleek
Copy link
Contributor

@daveleek daveleek commented Feb 8, 2024

About the changes

Adds migration for creating table stat_traffic_usage.
This table primary-keys on day, traffic_group, and status_code_series.

Traffic group is the grouping for API endpoints for which traffic is counted.
status_code_series is 200/202 etc = 200, 304 etc = 300

Copy link

vercel bot commented Feb 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2024 7:48am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Feb 9, 2024 7:48am

`
CREATE TABLE IF NOT EXISTS stat_traffic_usage(
day DATE NOT NULL,
traffic_group TEXT NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ended up naming this traffic_group as the group name we initially came up with was a reserved keyword in Postgresql

CREATE TABLE IF NOT EXISTS stat_traffic_usage(
day DATE NOT NULL,
traffic_group TEXT NOT NULL,
status_code_series INT NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

appended a _series to make it clear that it's 200/300 etc, not 200/201/202/304 etc

@chriswk
Copy link
Member

chriswk commented Feb 8, 2024

@gardleopard , @sjaanus do you think this would do for storing 400 days of data for visitation stats?

@chriswk
Copy link
Member

chriswk commented Feb 8, 2024

I think creating subindexes on day, traffic_group and status_code_series could help. the PK index will be a thruple of (day, tg, scs), so if we want to do where status_code_series = 200 it will be a table scan.

@daveleek
Copy link
Contributor Author

daveleek commented Feb 8, 2024

Thanks @chriswk - I've added the suggested indexes

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

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

LGTM

@daveleek daveleek merged commit 1b1bde8 into main Feb 9, 2024
14 checks passed
@daveleek daveleek deleted the chore/traffic-data-collection-table-migration branch February 9, 2024 08:58
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