Browse Source

Added songsRequested attribute for user logic

theflametrooper 8 năm trước cách đây
mục cha
commit
62fcdee983
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      backend/logic/actions/queueSongs.js

+ 12 - 0
backend/logic/actions/queueSongs.js

@@ -161,6 +161,18 @@ module.exports = {
 					if (err) return next(err);
 					next(null, newSong);
 				});
+			},
+			(newSong, next) => {
+				db.models.user.findOne({ _id: userId }, (err, user) => {
+					if (err) next(err, newSong);
+					else {
+						user.statistics.songsRequested = user.statistics.songsRequested + 1;
+						user.save(err => {
+							if (err) return next(err, newSong);
+							else next(null, newSong);
+						});
+					}
+				});
 			}
 		], (err, newSong) => {
 			if (err) {