-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove time ranges, refactor listen fetching and improve listen count…
…/timestamp caching (#1390) * Create an improved listen_count_week view that will perform better for our data. Start removing time_range arguments for fetching listens, and start using listen_count_week to fetch listens accurately. * Committing some notes for timescale tweaking * Interim check-in * Remove time range fetching mechanism from front-end * Remove erroneously commited change * Small cleanup * Commit more notes after more tinkering * Improve listen_count continuous aggregated, add indexes to the materialized view and drop min/max continuous aggregates and use the listen_count indexes instead. * Tests for updated listen fetching now pass * Finished fixing last bugs * Make timestamps accurate -- its slower, but really a must * CHERRYPICK: This PR renames the listen_count agg to listen_count_5day so taht we may test this code on the test server. We may be able to rename indexes, in which case we will need to undo this commit. This making it clear what this PR is for. * Fix an off by one error * listen count fixes * Add some documentation to this complex function * Add timing for the timestamp and fetch listens functions * Improve timing output * CHERRYPICK: This commit undoes the fancy footwork listen_count table to optimize the lookup of listens, which actually became slower. :( * Interim check-in * Finish debugging the exponential backoff problem * peppy and fix a comment * Mostly a made up commit so I can test the new testing setup. Failures ensured! * Refactor timestamps to not expire and use them to bound query lookups. * Undo create use set timestamps, it needs to be done elsewhere. ALso fix another test. * Fix an invocation to fetch listens * Fixing more tests * Refactor timestamps code * Fix a constant * Fix last failing tests.. I hope * One final test fixed * More cache key cleanup and set timestamps for newly created user. * Query timestamps directly * Make cache calls consistent * More timestamp cleanup * Update snapshot * Fix the incorrect listen count * Cleanup cache in redis listenstore as well * Minor fixes * Fix upper end check * Peppy * Minor cleanup * Update snapshot After merging master * Start migrating to TS 2.2 * Update for timescale 2.2.0. Remove code to create index by hand, can be done with static sql now. However, tests all fail for some mysterious reason. * Use simpler group-by * Pin 2.2.0-pg11 image tag (#1426) * Fix tests * Update snapshot * Just kidding, just because the continous aggregate is now a materialized view and that it is possible to create indexes on materialized views, its not possible to do so on *these* views. * Fix tests * Fix some tests some issues after a bad merge * Improve timing related debug output * Don't load feedback if no current user We had a bad assertion when current user was undefined: undefined===undefined = true * Fix recentlistens tests don't connect to websocket server by default, and some modification of the test props (latestListenTs) * Fix debug statement * PR feedback * Listenstore PR feedback improvements * Remove superfluous order/group by * Recalculate all user data (#1396) * Add tabulation script * If an account has no listens, dont update anything. * Move recalculate_all_user_data to a separate module * Remove function from listenstore * Pepperson Co-authored-by: Monkey Do <contact@monkeydo.digital> Co-authored-by: Kartik Ohri <kartikohri13@gmail.com>
- Loading branch information
1 parent
2af210b
commit 498577f
Showing
38 changed files
with
1,657 additions
and
2,884 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,2 @@ | ||
BEGIN; | ||
|
||
CREATE VIEW listen_count | ||
WITH (timescaledb.continuous, timescaledb.refresh_lag=43200, timescaledb.refresh_interval=3600) | ||
AS SELECT time_bucket(bigint '86400', listened_at) AS listened_at_bucket, user_name, count(listen) | ||
FROM listen group by time_bucket(bigint '86400', listened_at), user_name; | ||
|
||
CREATE VIEW listened_at_max | ||
WITH (timescaledb.continuous, timescaledb.refresh_lag=43200, timescaledb.refresh_interval=3600) | ||
AS SELECT time_bucket(bigint '86400', listened_at) AS listened_at_bucket, user_name, max(listened_at) AS max_value | ||
FROM listen group by time_bucket(bigint '86400', listened_at), user_name; | ||
|
||
CREATE VIEW listened_at_min | ||
WITH (timescaledb.continuous, timescaledb.refresh_lag=43200, timescaledb.refresh_interval=3600) | ||
AS SELECT time_bucket(bigint '86400', listened_at) AS listened_at_bucket, user_name, min(listened_at) AS min_value | ||
FROM listen group by time_bucket(bigint '86400', listened_at), user_name; | ||
|
||
COMMIT; | ||
-- 2592000 is number of seconds in 30 days | ||
CREATE MATERIALIZED VIEW listen_count_30day WITH (timescaledb.continuous) AS SELECT time_bucket(bigint '2592000', listened_at) AS listened_at_bucket, user_name, count(listen) FROM listen GROUP BY listened_at_bucket, user_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
BEGIN; | ||
|
||
DROP VIEW listen_count CASCADE; | ||
DROP VIEW listen_count_30day CASCADE; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.