Skip to content

Instantly share code, notes, and snippets.

View mayhem's full-sized avatar
💭
Hell bent on total world domination!

Robert Kaye mayhem

💭
Hell bent on total world domination!
View GitHub Profile
diff --git a/manage.py b/manage.py
index 5676023b..9a3699a2 100644
--- a/manage.py
+++ b/manage.py
@@ -196,6 +196,8 @@ def init_db(force, create_db):
res = ts.run_sql_script_without_transaction(os.path.join(TIMESCALE_SQL_DIR, 'create_extensions.sql'))
# Don't raise an exception if the extension already exists
+
+ ts.init_db_connection(config.SQLALCHEMY_TIMESCALE_URI)
2020-06-05 10:20:52,522 INFO Total number of users: 9673
2020-06-05 10:21:53,443 INFO Listens for user rob dumped, total 106877 listens written at 1754.62 listens / sec!
2020-06-05 10:21:53,444 INFO 1 users done. Total: 9673
2020-06-05 10:22:33,393 INFO Listens for user iliekcomputers dumped, total 90342 listens written at 2261.41 listens / sec!
2020-06-05 10:22:33,393 INFO 2 users done. Total: 9673
2020-06-05 10:23:03,089 INFO Listens for user marc2k3 dumped, total 128 listens written at 4.31 listens / sec!
2020-06-05 10:23:03,090 INFO 3 users done. Total: 9673
2020-06-05 10:23:17,311 INFO Listens for user nasasie_test dumped, total 0 listens written at 0.00 listens / sec!
2020-06-05 10:23:17,311 INFO 4 users done. Total: 9673
2020-06-05 10:23:51,498 INFO Listens for user Schmias dumped, total 32214 listens written at 942.31 listens / sec!
04 - Chinese Democracy- Street Of Dreams Guns N' Roses
04 - Cornshucker Guns N' Roses
2 cornshuckergunsnroses 21689653
04 Guns & Roses - Human Being Guns N' Roses
04 Guns & Roses - Knockin' on Heaven Guns N' Roses
04 guns & roses - mama kin Guns N' Roses
04.Out Ta Get Me Guns N' Roses
2 outtagetmegunsnroses 153728
04 The garden Guns N' Roses
2 thegardengunsnroses 165306
INFO listenbrainz.listenstore.tests.test_timescalelistenstore:timescale_listenstore.py:198 {'artist_msid': '4b414191-eb7f-4189-b198-64e43773b8e8',
'data': {'additional_info': {},
'artist_name': 'Frank Ocean',
'track_name': 'Crack Rock'},
'dedup_tag': 0,
'inserted_timestamp': None,
'recording_msid': '4b86f9b8-300a-49d4-a130-1a1376cbe6bb',
'release_msid': None,
'timestamp': datetime.datetime(1970, 1, 1, 0, 0, 10),
'ts_since_epoch': 10,
>>> a = { 1: 2, 3 : 4 }
>>> b = a.copy()
>>> b
{1: 2, 3: 4}
>>> del b[1]
>>> a
{1: 2, 3: 4}
>>> b
{3: 4}
>>>
track_metadata = self.data.copy()
track_metadata['additional_info']['artist_msid'] = self.artist_msid
track_metadata['additional_info']['release_msid'] = self.release_msid
track_metadata['additional_info']['recording_msid'] = self.recording_msid
track_name = track_metadata['track_name']
del track_metadata['track_name']
[
{
"user_id": "-- the MusicBrainz ID of the user --",
"recording_msid": "d23f4719-9212-49f0-ad08-ddbfbfc50d6f",
"score": 1
},
{
. .
}
]
STOP:
hip:
docker stop metabrainz-prod ; docker rm metabrainz-prod
trille:
docker stop critiquebrainz-beta critiquebrainz-prod && docker rm critiquebrainz-beta critiquebrainz-prod
@mayhem
mayhem / gist:08f01f0308439c323e1fc4e4d7eec8e0
Created May 20, 2020 00:12
popular artists and their most popular tracks
1185572 The Beatles
13620 come together
13207 let it be
12236 eleanor rigby
11605 here comes the sun
11497 something
1165437 Radiohead
28917 karma police
26509 creep
25758 paranoid android
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, user_name, max(listened_at)
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, user_name, min(listened_at)
FROM listen group by time_bucket(bigint '86400', listened_at), user_name;