Skip to content

Instantly share code, notes, and snippets.

Tracks similar to: ['Tell Me The Truth - Live @ The Metro', 'Midnight Oil', '0941818c-5e44-4ed4-9b7e-2516b2f5ccc8']
('Cheating Synergy', 'Kylesa', 'fac7c6e0-a9d3-4bf5-a657-d2e8cc5cf95f')
("The Lord's Prayer (feat. Sandra McCracken)", 'Rain For Roots', '73db218f-f47c-46ea-ba26-843f5f3b9c36')
('Independente (Ladies Night)', 'Wanessa', '2c39e05b-b3ed-49ec-b853-1e148a180130')
('Vague (variation)', 'Anouar Brahem', 'f1a47a05-d307-4ec9-b074-f801bdd79d24')
('sexy girl (remix)', 'Dr Dj Cerla', '61e2c6cd-dee5-4186-a2c2-e762f582aa03')
('Last Dream Of A Galaxy Warrior', 'Eguana', '93ffebbc-04f7-4994-8116-429390ac7c65')
('The End Of The World', 'Avengers', '59423576-1baa-491a-ada2-4befadd05b0c')
('What If Everyone Can Do It?', 'Countdown to Putsch', '36b3d359-a703-444f-a1ac-366851d5ba24')
('Going With The Punks', 'Lo Fat Orchestra', 'adb50729-3f7d-4282-90be-16d31fb46ef1')
_______________________________________________________________________ RedisListenStoreTestCase.test_update_and_get_recent_listens ________________________________________________________________________
self = <listenbrainz.listenstore.tests.test_redislistenstore.RedisListenStoreTestCase testMethod=test_update_and_get_recent_listens>
def test_update_and_get_recent_listens(self):
recent = self._redis.get_recent_listens()
self.assertEqual(recent, [])
listens = []
SELECT DISTINCT t1.release_name
, t1.artist_name
, t2.artist_name
, t1.release_msid
, t2.release_msid
FROM listens_df t1
INNER JOIN listens_df t2
ON t1.release_msid = t2.release_msid
+--------------------+--------------------+--------------------+--------------------+--------------------+
SELECT t1.name, t2.name from artist t1 join artust t2 on t1.area = t2.area;
musicbrainz_db=# explain SELECT t1.name, t2.name from artist t1 join artist t2 on t1.area = t2.area;
QUERY PLAN
-------------------------------------------------------------------------------------------
Nested Loop (cost=0.43..27166980.27 rows=26286757159 width=26)
-> Seq Scan on artist t1 (cost=0.00..37568.81 rows=1496681 width=17)
-> Index Scan using artist_idx_area on artist t2 (cost=0.43..11.72 rows=641 width=17)
Index Cond: (area = t1.area)
(4 rows)
def test_get_listens(self):
""" Test to make sure that the api sends valid listens on get requests.
"""
with open(self.path_to_data_file('valid_single.json'), 'r') as f:
payload = json.load(f)
# send a listen
ts = int(time.time())
payload['payload'][0]['listened_at'] = ts
recommendations = {
'user_name': {
'type': {
'top_artist': [recording_msid1, recording_msid2....recording_msidN],
'similar_artist': [recording_msid1, recording_msid2....recording_msidN]
}
}
}
# for utils.py
def get_listens(y, m1, m2):
""" Loads all the listens listened to in a given time window from HDFS.
Args:
y (int): Year to load parquets.
m1 (int): Load parquets from month m1.
m2 (int): Load parquets till month m2.
Returns:
#stats.replace_days
def replace_days(day):
date = datetime.utcnow().replace(day=day)
return date
def create_training_data_from_window():
""" Prepare dataframe of listens of X months where X is a config value.
Returns:
training_df (dataframe): Columns can de depicted as:
CREATE TYPE cf_recording_type AS ENUM('top_artist', 'similar_artist')
CREATE TABLE recommendation.cf_recording (
id SERIAL, --PK
user_id INTEGER, --FK to "user".id
recording_msid UUID NOT NULL,
type cf_recording_type,
created TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);