Skip to content

Commit

Permalink
Merge branch 'main' into auth0-after-bulk-user-import
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed Oct 15, 2023
2 parents 43f6fe6 + 6652771 commit ab5811f
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 363 deletions.
16 changes: 8 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
# - package-ecosystem: 'github-actions'
# directory: '/'
# schedule:
# interval: 'weekly'

# Maintain dependencies for npm
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
# - package-ecosystem: 'npm'
# directory: '/'
# schedule:
# interval: 'weekly'
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.57.1](https://github.com/openwhyd/openwhyd/compare/v1.57.0...v1.57.1) (2023-10-11)


### Bug Fixes

* **logs:** reduce error logs from fieldSetters ([#747](https://github.com/openwhyd/openwhyd/issues/747)) ([68b3ab3](https://github.com/openwhyd/openwhyd/commit/68b3ab3bb4d3b160ee1cd62f4844c1456c0cf0a5))

# [1.57.0](https://github.com/openwhyd/openwhyd/compare/v1.56.8...v1.57.0) (2023-09-21)


### Features

* **hot-tracks:** 🧹 remove computation of relative ranking trends ([#737](https://github.com/openwhyd/openwhyd/issues/737)) ([1eed523](https://github.com/openwhyd/openwhyd/commit/1eed523396ff5dc13d9e1f3c1023b59827ba3fc0))

## [1.56.8](https://github.com/openwhyd/openwhyd/compare/v1.56.7...v1.56.8) (2023-09-20)


Expand Down
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ function start() {
console.log(`[app] Server running at ${url}`);
});
require('./app/workers/notifEmails.js'); // start digest worker
require('./app/workers/hotSnapshot.js'); // start hot tracks snapshot worker

function closeGracefully(signal) {
console.warn(`[app] ${signal} signal received: closing server...`);
Expand Down
13 changes: 0 additions & 13 deletions app/controllers/admin/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
**/

const mongodb = require('../../models/mongodb.js');
const trackModel = require('../../models/track.js');
const snip = require('../../snip.js');
const FileController = require('./FileController.js');

Expand Down Expand Up @@ -57,18 +56,6 @@ function listMissingUsers(uids, cb) {
}

var fileGenerators = {
refreshTrackCollection: function (p, cb) {
trackModel.refreshTrackCollection(function (r) {
console.log('refreshTrackCollection => ', r || { ok: 'done' });
});
cb('refreshing track collection...');
},
snapshotTrackScores: function (p, cb) {
trackModel.snapshotTrackScores(function (r) {
console.log('snapshotTrackScores => ', r || { ok: 'done' });
});
cb('refreshing track trends...');
},
'listUsersWithoutPosts.html': async function (p, cb) {
const uidList = await fetchUidList();
listMissingUsers(cleanUidList(uidList), function (users) {
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,9 @@ const fieldSetters = {
console.log('deleting previous profile pic: ' + user.img);
await uploadCtr
.deleteFile(user.img)
.catch((err) =>
.catch(() =>
console.log(
'failed to delete existing profile image in fieldSetters.img',
err,
err.stack,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/private/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function fetchTheirPosts(q, uid, cb) {
function fetchSearchPage(myUid, q, cb) {
fetchResultsPerType({ q: q }, function (resultsPerType) {
followModel.fetchSubscriptionSet(myUid, function (followedUids) {
const types = ['track', 'user', 'playlist'];
const types = ['user', 'playlist'];
const results = {};
(function next() {
if (!types.length) {
Expand Down
16 changes: 0 additions & 16 deletions app/features/hot-tracks.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
// @ts-check

const FIELDS_TO_SUM = {
nbP: true, // number of plays
nbL: true, // number of likes (from lov[] field)
nbR: true, // number of posts/reposts
};

exports.FIELDS_TO_SUM = FIELDS_TO_SUM;

const FIELDS_TO_COPY = {
name: true,
img: true,
score: true,
};

exports.FIELDS_TO_COPY = FIELDS_TO_COPY;

/**
* @param {() => Promise<{pId: string, eId: string}[]>} getTracksByDescendingScore (partial type definition, just to check usage of objArrayToValueArray)
*/
Expand Down
17 changes: 5 additions & 12 deletions app/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const snip = require('../snip.js');
const notif = require('../models/notif.js');
const searchModel = require('../models/search.js');
const activityModel = require('../models/activity.js');
const trackModel = require('../models/track.js');
const notifModel = require('../models/notif.js');

const NB_POSTS = process.appParams?.nbPostsPerNewsfeedPage;
Expand Down Expand Up @@ -202,7 +201,6 @@ async function setPostLove(collection, pId, uId, state, handler) {
const post = await collection.findOne({ _id: ObjectId('' + pId) });
if (post && uId != post.uId) notif[state ? 'love' : 'unlove'](uId, post);
handler?.(post);
if (post) trackModel.updateByEid(post.eId);
if (state)
activityModel.addLikeByPost(post, {
id: uId,
Expand Down Expand Up @@ -319,11 +317,10 @@ exports.rePost = function (pId, repostObj, handler) {
if (repostObj.uId != repostObj.repost.uId) {
notif.repost(repostObj.uId, postObj);
notif.post(postObj);
collection
.updateOne({ _id: ObjectId('' + pId) }, { $inc: { nbR: 1 } })
.then(() => {
trackModel.updateByEid(postObj.eId);
});
collection.updateOne(
{ _id: ObjectId('' + pId) },
{ $inc: { nbR: 1 } },
);
}
const post = await mongodb.collections['post'].findOne({
_id: ObjectId('' + result.insertedId),
Expand Down Expand Up @@ -366,7 +363,6 @@ exports.deletePost = function (pId, uId, handler) {
{ _id: ObjectId('' + postObj.repost.pId) },
{ $inc: { nbR: -1 } },
);
trackModel.updateByEid(postObj.eId);
} else {
handler(new Error('post not found'));
}
Expand All @@ -383,10 +379,7 @@ exports.incrPlayCounter = function (pId, cb) {
}
mongodb.collections['post'].updateOne({ _id }, { $inc: { nbP: 1 } }).then(
async (/*updateRes*/) => {
const post = await new Promise((resolve) =>
exports.fetchPostById(pId, resolve),
);
if (post?.eId) trackModel.updateByEid(post.eId);
await new Promise((resolve) => exports.fetchPostById(pId, resolve));
cb?.({});
},
(err) => cb?.(err) ?? console.trace('incrPlayCounter', err),
Expand Down
22 changes: 1 addition & 21 deletions app/models/searchAlgolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
**/

const snip = require('../snip.js');
const mongodb = require('./mongodb.js');
const algoliasearch = require('algoliasearch');

if (process.env['ALGOLIA_APP_ID'] === undefined)
Expand All @@ -19,14 +18,12 @@ const client = algoliasearch(

const INDEX_NAME_BY_TYPE = {
user: 'users',
track: 'tracks',
post: 'posts',
playlist: 'playlists',
};

const INDEX_TYPE_BY_NAME = {
users: 'user',
tracks: 'track',
posts: 'post',
playlists: 'playlist',
};
Expand Down Expand Up @@ -153,23 +150,6 @@ const searchByType = {
// tested http://localhost:8080/search?q=pouet&context=header
// => { q: 'pouet' }
},
track: function (q, cb) {
console.log('[search] search tracks', q);
const options = extractOptions(q);
return searchIndex.search(
'tracks',
q.q,
options,
makeCallbackTranslator('track', function (res) {
(res.hits || []).map(function (h) {
h.eId = h._id;
h._id = mongodb.ObjectId(h.post);
delete h.post;
});
cb(res);
}),
);
},
post: function (q, cb) {
console.log('[search] search posts', q);
const options = extractOptions(q);
Expand Down Expand Up @@ -233,7 +213,7 @@ exports.query = function (q = {}, cb) {
let queue;
if (q._type) queue = [q._type];
else if (q.uId) queue = ['post'];
else queue = ['user', 'track', 'post', 'playlist']; //Object.keys(searchByType);
else queue = ['user', 'post', 'playlist']; //Object.keys(searchByType);
delete q._type;
(function next() {
const type = queue.pop();
Expand Down
Loading

0 comments on commit ab5811f

Please sign in to comment.