Skip to content

Commit

Permalink
feat: Remove "Playlist Contest" (#388)
Browse files Browse the repository at this point in the history
Contributes to #318.

The "Playlist Contest" feature is not used anymore => let's clean-up.
  • Loading branch information
adrienjoly committed Nov 11, 2020
1 parent 58af958 commit 39bd559
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 1,136 deletions.
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var params = (process.appParams = {
// workers and general site logic
searchModule: 'searchAlgolia', // "searchElastic" // "" => no search index
// recomPopulation: true, // populate recommendation index at startup
advertisePlaylistContestOnHome: false, // jamendo playlist contest

// email notification preferences
emailModule: 'emailSendgrid', // "DISABLED"/"null" => fake email sending
Expand Down
9 changes: 1 addition & 8 deletions app/controllers/LibFriends.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* @author adrienjoly, whyd
**/

var config = require('../models/config.js');
var postModel = require('../models/post.js');
var followModel = require('../models/follow.js');
var activityModel = require('../models/activity.js');
var contestModel = require('../models/plContest.js');
var feedTemplate = require('../templates/feed.js');

var HISTORY_LIMIT = 3;
Expand Down Expand Up @@ -49,12 +47,7 @@ function prepareSidebar(uidList, options, cb) {
if (activities && activities.length)
options.recentActivity = { items: activities };
//console.time("fetchLast");
contestModel.fetchLast(function (contest) {
//console.timeEnd("fetchLast");
if (config.advertisePlaylistContestOnHome && contest && contest.title)
options.playlistContest = contest;
cb();
});
cb();
});
} else cb();
}
Expand Down
55 changes: 23 additions & 32 deletions app/controllers/LibUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var mongodb = require('../models/mongodb.js');
var userModel = require('../models/user.js');
var followModel = require('../models/follow.js');
var postModel = require('../models/post.js');
var contestModel = require('../models/plContest.js');
var activityModel = require('../models/activity.js');
var activityController = require('../controllers/recentActivity.js');
var feedTemplate = require('../templates/feed.js');
Expand Down Expand Up @@ -248,41 +247,33 @@ function fetchAndRenderPlaylist(options, callback, process) {
options.user.name;
}
if (!options.playlist) callback('meh... this playlist does not exist!');
else
contestModel.fetchByTitle((options.playlist || {}).name, function (
contest
) {
var prevId = null;
for (let p = options.user.pl.length - 1; p > -1; --p) {
var pl = options.user.pl[p];
if (!pl) continue;
if (pl.id == options.playlistId) {
if (prevId !== null)
options.prevPageInList =
'/u/' + options.uid + '/playlist/' + prevId;
for (--p; p > -1; --p) {
if (options.user.pl[p]) {
options.nextPageInList =
'/u/' + options.uid + '/playlist/' + options.user.pl[p].id;
break;
}
else {
var prevId = null;
for (let p = options.user.pl.length - 1; p > -1; --p) {
var pl = options.user.pl[p];
if (!pl) continue;
if (pl.id == options.playlistId) {
if (prevId !== null)
options.prevPageInList = '/u/' + options.uid + '/playlist/' + prevId;
for (--p; p > -1; --p) {
if (options.user.pl[p]) {
options.nextPageInList =
'/u/' + options.uid + '/playlist/' + options.user.pl[p].id;
break;
}
break;
}
prevId = pl.id;
break;
}
prevId = pl.id;
}

if (options.playlist && contest && contest.title) {
options.playlist.inContest = contest;
options.bodyClass += ' inContest';
}
postModel.fetchPlaylistPosts(
options.uid,
options.playlistId,
options.fetchParams,
process
);
});
postModel.fetchPlaylistPosts(
options.uid,
options.playlistId,
options.fetchParams,
process
);
}
}

function fetchAndRenderProfile(options, callback, process) {
Expand Down
133 changes: 0 additions & 133 deletions app/controllers/playlistcontest.js

This file was deleted.

20 changes: 2 additions & 18 deletions app/controllers/private/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var userModel = require('../../models/user.js');
var followModel = require('../../models/follow.js');
var emailModel = require('../../models/email.js'); // for validation
var notifModel = require('../../models/notif.js');
var contestModel = require('../../models/plContest.js');
var inviteController = require('../invite.js');
var userApi = require('../../controllers/api/user.js');
var htmlRedirect = require('../../templates/logging.js').htmlRedirect;
Expand Down Expand Up @@ -198,27 +197,12 @@ exports.registerInvitedUser = function (request, user, response) {
notifModel.inviteAccepted(user.iBy, storedUser);
}

if (user.plContest)
userModel.createPlaylist(storedUser._id, user.plContest.title, function (
playlist
) {
loginAndRedirectTo('/u/' + storedUser._id + '/playlist/' + playlist.id);
});
else {
loginAndRedirectTo(onboardingUrl || '/');
}
loginAndRedirectTo(onboardingUrl || '/');
}

if (user.iBy || checkInvites)
inviteController.checkInviteCode(request, user, response, function () {
if (user.plC)
contestModel.fetchById(user.plC, function (plContest) {
if (!plContest)
console.error('plcontest not found when trying to signup');
else user.plContest = plContest;
registerUser();
});
else registerUser();
registerUser();
});
else registerUser();
};
Expand Down
Loading

0 comments on commit 39bd559

Please sign in to comment.