Skip to content

Commit

Permalink
🧹 drop the track collection
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed Sep 20, 2023
1 parent 511ae76 commit 0652dd3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
35 changes: 0 additions & 35 deletions app/models/track.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
// @ts-check

/**
* track model
* - maintained by post model: updateByEid()
* - read by hot tracks controller: getHotTracksFromDb()
* - read by notif template: getHotTracksFromDb()
* @author adrienjoly, whyd
**/

/*
- - - structure of a track record - - -
_id: automatically-assigned identifier (ObjectId)
eId: uri used to identify and embed this track's stream from its source
img: url of the image thumb of that track
name: name of the track (combines artist and title) // TODO: which version is stored in case of conflict?
score: the higher this number, the higher this track will rank in the hot tracks. computed from various metrics.
nbR: number of posts/reposts within the HOT_TRACK_TIME_WINDOW period
nbL: number of likes
nbP: number of plays
prev: score value at last snapshot (used to compute trends)
meta: {art, tit, dur, c, t}: concise metadata extracted from 3rd-parties (artist name, track title, duration, confidence 0<1, timestamp)
alt: [eId1, eId2...]: array of alternative souces for that track (cross-platform mappings)
- - - old fields - - -
prevRank: used to store the rank/index of that record in the track collection, before the score was updated
nbFreshPosts: used to store the number of posts within the HOT_TRACK_TIME_WINDOW
nbTotalPosts: duplicate of nbR
nbTotalLikes: duplicate of nbL
nbTotalPlays: duplicate of nbP
- - - notice - - -
since the periodic call of refreshHotTracksCache() was removed:
-> the prevRank is never updated => no movement information will be displayed on openwhyd.org/hot
-> the score of a track will only be updated on a (re-)post, like, or play operation on that track
*/

const config = require('./config.js');
const mongodb = require('./mongodb.js');
const feature = require('../features/hot-tracks.js');
Expand Down
6 changes: 1 addition & 5 deletions config/initdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ await Promise.all([
db.createCollection('follow').catch(tolerateError('already exists')),
db.createCollection('post').catch(tolerateError('already exists')),
db.createCollection('activity').catch(tolerateError('already exists')),
db.createCollection('track').catch(tolerateError('already exists')),
db.dropCollection('track').catch(tolerateError('ns not found')),
db.createCollection('comment').catch(tolerateError('already exists')),
]);

Expand Down Expand Up @@ -64,10 +64,6 @@ await db
.collection('activity')
.createIndex({ 'like.pId': 1 }, { sparse: true });

// print('indexing track collection...');
await db.collection('track').createIndex({ eId: 1 });
await db.collection('track').createIndex({ score: 1 });

// print('indexing comment collection...');
await db.collection('comment').createIndex({ pId: 1 });

Expand Down

0 comments on commit 0652dd3

Please sign in to comment.