Browse Source

fix: Eslint fixes

Owen Diffey 2 years ago
parent
commit
aac31677c5
3 changed files with 260 additions and 490 deletions
  1. 132 128
      backend/logic/actions/playlists.js
  2. 5 1
      backend/logic/db/schemas/playlist.js
  3. 123 361
      backend/package-lock.json

+ 132 - 128
backend/logic/actions/playlists.js

@@ -2733,47 +2733,48 @@ export default {
 	clearAndRefillArtistPlaylist: useHasPermission(
 	clearAndRefillArtistPlaylist: useHasPermission(
 		"playlists.clearAndRefill",
 		"playlists.clearAndRefill",
 		async function index(session, playlistId, cb) {
 		async function index(session, playlistId, cb) {
-		async.waterfall(
-			[
-				next => {
-					if (!playlistId) next("Please specify a playlist id");
-					else {
-						PlaylistsModule.runJob("CLEAR_AND_REFILL_ARTIST_PLAYLIST", { playlistId }, this)
-							.then(() => {
-								next();
-							})
-							.catch(err => {
-								next(err);
-							});
+			async.waterfall(
+				[
+					next => {
+						if (!playlistId) next("Please specify a playlist id");
+						else {
+							PlaylistsModule.runJob("CLEAR_AND_REFILL_ARTIST_PLAYLIST", { playlistId }, this)
+								.then(() => {
+									next();
+								})
+								.catch(err => {
+									next(err);
+								});
+						}
+					}
+				],
+				async err => {
+					if (err) {
+						err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
+
+						this.log(
+							"ERROR",
+							"PLAYLIST_CLEAR_AND_REFILL_ARTIST_PLAYLIST",
+							`Clearing and refilling artist playlist "${playlistId}" failed for user "${session.userId}". "${err}"`
+						);
+
+						return cb({ status: "error", message: err });
 					}
 					}
-				}
-			],
-			async err => {
-				if (err) {
-					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
 
 
 					this.log(
 					this.log(
-						"ERROR",
+						"SUCCESS",
 						"PLAYLIST_CLEAR_AND_REFILL_ARTIST_PLAYLIST",
 						"PLAYLIST_CLEAR_AND_REFILL_ARTIST_PLAYLIST",
-						`Clearing and refilling artist playlist "${playlistId}" failed for user "${session.userId}". "${err}"`
+						`Successfully cleared and refilled artist playlist "${playlistId}" for user "${session.userId}".`
 					);
 					);
 
 
-					return cb({ status: "error", message: err });
+					return cb({
+						status: "success",
+						message: "Playlist has been successfully cleared and refilled"
+					});
 				}
 				}
-
-				this.log(
-					"SUCCESS",
-					"PLAYLIST_CLEAR_AND_REFILL_ARTIST_PLAYLIST",
-					`Successfully cleared and refilled artist playlist "${playlistId}" for user "${session.userId}".`
-				);
-
-				return cb({
-					status: "success",
-					message: "Playlist has been successfully cleared and refilled"
-				});
-			}
-		);
-	}),
+			);
+		}
+	),
 
 
 	/**
 	/**
 	 * Clears and refills all station playlists
 	 * Clears and refills all station playlists
@@ -2972,111 +2973,114 @@ export default {
 	 * @param {object} session - the session object automatically added by socket.io
 	 * @param {object} session - the session object automatically added by socket.io
 	 * @param {Function} cb - gets called with the result
 	 * @param {Function} cb - gets called with the result
 	 */
 	 */
-	clearAndRefillAllArtistPlaylists: useHasPermission("playlists.clearAndRefillAll", async function index(session, cb) {
-		this.keepLongJob();
-		this.publishProgress({
-			status: "started",
-			title: "Clear and refill all artist playlists",
-			message: "Clearing and refilling all artist playlists.",
-			id: this.toString()
-		});
-		await CacheModule.runJob("RPUSH", { key: `longJobs.${session.userId}`, value: this.toString() }, this);
-		await CacheModule.runJob(
-			"PUB",
-			{
-				channel: "longJob.added",
-				value: { jobId: this.toString(), userId: session.userId }
-			},
-			this
-		);
-
-		async.waterfall(
-			[
-				next => {
-					PlaylistsModule.runJob("GET_ALL_ARTIST_PLAYLISTS", {}, this)
-						.then(response => {
-							next(null, response.playlists);
-						})
-						.catch(err => {
-							next(err);
-						});
+	clearAndRefillAllArtistPlaylists: useHasPermission(
+		"playlists.clearAndRefillAll",
+		async function index(session, cb) {
+			this.keepLongJob();
+			this.publishProgress({
+				status: "started",
+				title: "Clear and refill all artist playlists",
+				message: "Clearing and refilling all artist playlists.",
+				id: this.toString()
+			});
+			await CacheModule.runJob("RPUSH", { key: `longJobs.${session.userId}`, value: this.toString() }, this);
+			await CacheModule.runJob(
+				"PUB",
+				{
+					channel: "longJob.added",
+					value: { jobId: this.toString(), userId: session.userId }
 				},
 				},
+				this
+			);
 
 
-				(playlists, next) => {
-					async.eachLimit(
-						playlists,
-						1,
-						(playlist, next) => {
-							this.publishProgress({
-								status: "update",
-								message: `Clearing and refilling "${playlist._id}"`
+			async.waterfall(
+				[
+					next => {
+						PlaylistsModule.runJob("GET_ALL_ARTIST_PLAYLISTS", {}, this)
+							.then(response => {
+								next(null, response.playlists);
+							})
+							.catch(err => {
+								next(err);
 							});
 							});
-							PlaylistsModule.runJob(
-								"CLEAR_AND_REFILL_ARTIST_PLAYLIST",
-								{ playlistId: playlist._id },
-								this
-							)
-								.then(() => {
-									next();
-								})
-								.catch(err => {
-									next(err);
+					},
+
+					(playlists, next) => {
+						async.eachLimit(
+							playlists,
+							1,
+							(playlist, next) => {
+								this.publishProgress({
+									status: "update",
+									message: `Clearing and refilling "${playlist._id}"`
 								});
 								});
-						},
-						next
-					);
-				}
-				// next => {
-				// 	// PlaylistsModule.runJob("CREATE_MISSING_ARTIST_PLAYLISTS", {}, null)
-				// 	// 	.then()
-				// 	// 	.catch()
-				// 	// 	.finally(() => {
-				// 	// 		SongsModule.runJob("GET_ALL_ARTISTS", {}, null)
-				// 	// 			.then(response => {
-				// 	// 				const { artists } = response;
-				// 	// 				artists.forEach(artist => {
-				// 	// 					PlaylistsModule.runJob("AUTOFILL_ARTIST_PLAYLIST", { artist }, null).then().catch();
-				// 	// 				});
-				// 	// 			})
-				// 	// 			.catch();
-				// 	// 	});
-				// 	PlaylistsModule.runJob("GET_MISSING_ARTIST_PLAYLISTS", {}, this).then(response => {
-				// 		console.log(response);
-				// 	});
-				// }
-			],
-			async err => {
-				if (err) {
-					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
+								PlaylistsModule.runJob(
+									"CLEAR_AND_REFILL_ARTIST_PLAYLIST",
+									{ playlistId: playlist._id },
+									this
+								)
+									.then(() => {
+										next();
+									})
+									.catch(err => {
+										next(err);
+									});
+							},
+							next
+						);
+					}
+					// next => {
+					// 	// PlaylistsModule.runJob("CREATE_MISSING_ARTIST_PLAYLISTS", {}, null)
+					// 	// 	.then()
+					// 	// 	.catch()
+					// 	// 	.finally(() => {
+					// 	// 		SongsModule.runJob("GET_ALL_ARTISTS", {}, null)
+					// 	// 			.then(response => {
+					// 	// 				const { artists } = response;
+					// 	// 				artists.forEach(artist => {
+					// 	// 					PlaylistsModule.runJob("AUTOFILL_ARTIST_PLAYLIST", { artist }, null).then().catch();
+					// 	// 				});
+					// 	// 			})
+					// 	// 			.catch();
+					// 	// 	});
+					// 	PlaylistsModule.runJob("GET_MISSING_ARTIST_PLAYLISTS", {}, this).then(response => {
+					// 		console.log(response);
+					// 	});
+					// }
+				],
+				async err => {
+					if (err) {
+						err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
+
+						this.log(
+							"ERROR",
+							"PLAYLIST_CLEAR_AND_REFILL_ALL_ARTIST_PLAYLISTS",
+							`Clearing and refilling all artist playlists failed for user "${session.userId}". "${err}"`
+						);
+						this.publishProgress({
+							status: "error",
+							message: err
+						});
+						return cb({ status: "error", message: err });
+					}
 
 
 					this.log(
 					this.log(
-						"ERROR",
+						"SUCCESS",
 						"PLAYLIST_CLEAR_AND_REFILL_ALL_ARTIST_PLAYLISTS",
 						"PLAYLIST_CLEAR_AND_REFILL_ALL_ARTIST_PLAYLISTS",
-						`Clearing and refilling all artist playlists failed for user "${session.userId}". "${err}"`
+						`Successfully cleared and refilled all artist playlists for user "${session.userId}".`
 					);
 					);
 					this.publishProgress({
 					this.publishProgress({
-						status: "error",
-						message: err
+						status: "success",
+						message: "Playlists have been successfully cleared and refilled."
+					});
+					return cb({
+						status: "success",
+						message: "Playlists have been successfully cleared and refilled"
 					});
 					});
-					return cb({ status: "error", message: err });
 				}
 				}
-
-				this.log(
-					"SUCCESS",
-					"PLAYLIST_CLEAR_AND_REFILL_ALL_ARTIST_PLAYLISTS",
-					`Successfully cleared and refilled all artist playlists for user "${session.userId}".`
-				);
-				this.publishProgress({
-					status: "success",
-					message: "Playlists have been successfully cleared and refilled."
-				});
-				return cb({
-					status: "success",
-					message: "Playlists have been successfully cleared and refilled"
-				});
-			}
-		);
-	}),
+			);
+		}
+	),
 
 
 	/**
 	/**
 	 * Create missing genre playlists
 	 * Create missing genre playlists

+ 5 - 1
backend/logic/db/schemas/playlist.js

@@ -18,6 +18,10 @@ export default {
 	createdAt: { type: Date, default: Date.now, required: true },
 	createdAt: { type: Date, default: Date.now, required: true },
 	createdFor: { type: String },
 	createdFor: { type: String },
 	privacy: { type: String, enum: ["public", "private"], default: "private" },
 	privacy: { type: String, enum: ["public", "private"], default: "private" },
-	type: { type: String, enum: ["user", "user-liked", "user-disliked", "genre", "artist", "station", "admin"], required: true },
+	type: {
+		type: String,
+		enum: ["user", "user-liked", "user-disliked", "genre", "artist", "station", "admin"],
+		required: true
+	},
 	documentVersion: { type: Number, default: 6, required: true }
 	documentVersion: { type: Number, default: 6, required: true }
 };
 };

File diff suppressed because it is too large
+ 123 - 361
backend/package-lock.json


Some files were not shown because too many files changed in this diff