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

Investigate having configurable time period for sql summaries #34

Open
gm3dmo opened this issue Apr 30, 2023 · 1 comment
Open

Investigate having configurable time period for sql summaries #34

gm3dmo opened this issue Apr 30, 2023 · 1 comment

Comments

@gm3dmo
Copy link
Owner

gm3dmo commented Apr 30, 2023

In #18 there are time series summaries by hour. Can there be 5,10,15 minute summaries?

@gm3dmo
Copy link
Owner Author

gm3dmo commented Apr 30, 2023

SELECT strftime('%Y-%m-%d %H:%M:%S', datetime(strftime('%s', now) / 300 * 300, 'unixepoch')) AS bucket,
status, COUNT(*) AS count
FROM unicorn
GROUP BY bucket, status
ORDER BY bucket ASC;
SELECT strftime('%Y-%m-%d %H:%M:%S', datetime(strftime('%s', now) / 600 * 600, 'unixepoch')) AS bucket,
SUM(CASE WHEN status = '200' THEN 1 ELSE 0 END) AS status_200,
SUM(CASE WHEN status = '404' THEN 1 ELSE 0 END) AS status_404,
SUM(CASE WHEN status = '500' THEN 1 ELSE 0 END) AS status_500
FROM unicorn
GROUP BY bucket
ORDER BY bucket ASC;

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

No branches or pull requests

1 participant