Browse Source

refactor: eslint fixes

Kristian Vos 3 years ago
parent
commit
61fedc8570

+ 2 - 6
backend/logic/actions/dataRequests.js

@@ -33,8 +33,6 @@ export default {
 	 * @param cb
 	 */
 	getData: isAdminRequired(async function getSet(session, page, pageSize, properties, sort, queries, operator, cb) {
-		const dataRequestModel = await DBModule.runJob("GET_MODEL", { modelName: "dataRequest" }, this);
-
 		async.waterfall(
 			[
 				next => {
@@ -49,10 +47,8 @@ export default {
 							operator,
 							modelName: "dataRequest",
 							blacklistedProperties: [],
-							specialProperties: {
-							},
-							specialQueries: {
-							}
+							specialProperties: {},
+							specialQueries: {}
 						},
 						this
 					)

+ 1 - 3
backend/logic/actions/news.js

@@ -69,8 +69,6 @@ export default {
 	 * @param cb
 	 */
 	getData: isAdminRequired(async function getSet(session, page, pageSize, properties, sort, queries, operator, cb) {
-		const newsModel = await DBModule.runJob("GET_MODEL", { modelName: "news" }, this);
-
 		async.waterfall(
 			[
 				next => {
@@ -86,7 +84,7 @@ export default {
 							modelName: "news",
 							blacklistedProperties: [],
 							specialProperties: {
-								"createdBy": [
+								createdBy: [
 									{
 										$addFields: {
 											createdByOID: {

+ 3 - 3
backend/logic/actions/playlists.js

@@ -287,21 +287,21 @@ export default {
 							modelName: "playlist",
 							blacklistedProperties: [],
 							specialProperties: {
-								"totalLength": [
+								totalLength: [
 									{
 										$addFields: {
 											totalLength: { $sum: "$songs.duration" }
 										}
 									}
 								],
-								"songsCount": [
+								songsCount: [
 									{
 										$addFields: {
 											songsCount: { $size: "$songs" }
 										}
 									}
 								],
-								"createdBy": [
+								createdBy: [
 									{
 										$addFields: {
 											createdByOID: {

+ 10 - 4
backend/logic/actions/punishments.js

@@ -40,8 +40,6 @@ export default {
 	 * @param cb
 	 */
 	getData: isAdminRequired(async function getSet(session, page, pageSize, properties, sort, queries, operator, cb) {
-		const punishmentModel = await DBModule.runJob("GET_MODEL", { modelName: "punishment" }, this);
-
 		async.waterfall(
 			[
 				next => {
@@ -63,7 +61,13 @@ export default {
 											status: {
 												$cond: [
 													{ $eq: ["$active", true] },
-													{ $cond: [{ $gt: [new Date(), "$expiresAt"] }, "Inactive", "Active"] },
+													{
+														$cond: [
+															{ $gt: [new Date(), "$expiresAt"] },
+															"Inactive",
+															"Active"
+														]
+													},
 													"Inactive"
 												]
 											}
@@ -159,7 +163,9 @@ export default {
 							},
 							specialQueries: {
 								value: newQuery => ({ $or: [newQuery, { valueUsername: newQuery.value }] }),
-								punishedBy: newQuery => ({ $or: [newQuery, { punishedByUsername: newQuery.punishedBy }] })
+								punishedBy: newQuery => ({
+									$or: [newQuery, { punishedByUsername: newQuery.punishedBy }]
+								})
 							}
 						},
 						this

+ 1 - 3
backend/logic/actions/reports.js

@@ -72,8 +72,6 @@ export default {
 	 * @param cb
 	 */
 	getData: isAdminRequired(async function getSet(session, page, pageSize, properties, sort, queries, operator, cb) {
-		const reportModel = await DBModule.runJob("GET_MODEL", { modelName: "report" }, this);
-
 		async.waterfall(
 			[
 				next => {
@@ -89,7 +87,7 @@ export default {
 							modelName: "report",
 							blacklistedProperties: [],
 							specialProperties: {
-								"createdBy": [
+								createdBy: [
 									{
 										$addFields: {
 											createdByOID: {

+ 8 - 4
backend/logic/actions/songs.js

@@ -203,7 +203,7 @@ export default {
 							modelName: "song",
 							blacklistedProperties: [],
 							specialProperties: {
-								"requestedBy": [
+								requestedBy: [
 									{
 										$addFields: {
 											requestedByOID: {
@@ -238,7 +238,7 @@ export default {
 										}
 									}
 								],
-								"verifiedBy": [
+								verifiedBy: [
 									{
 										$addFields: {
 											verifiedByOID: {
@@ -281,8 +281,12 @@ export default {
 								]
 							},
 							specialQueries: {
-								"requestedBy": newQuery => ({ $or: [newQuery, { requestedByUsername: newQuery.requestedBy }] }),
-								"verifiedBy": newQuery => ({ $or: [newQuery, { verifiedByUsername: newQuery.verifiedBy }] })
+								requestedBy: newQuery => ({
+									$or: [newQuery, { requestedByUsername: newQuery.requestedBy }]
+								}),
+								verifiedBy: newQuery => ({
+									$or: [newQuery, { verifiedByUsername: newQuery.verifiedBy }]
+								})
 							}
 						},
 						this

+ 1 - 1
backend/logic/actions/stations.js

@@ -666,7 +666,7 @@ export default {
 							modelName: "station",
 							blacklistedProperties: [],
 							specialProperties: {
-								"owner": [
+								owner: [
 									{
 										$addFields: {
 											ownerOID: {

+ 6 - 5
backend/logic/actions/users.js

@@ -214,8 +214,6 @@ export default {
 	 * @param cb
 	 */
 	getData: isAdminRequired(async function getSet(session, page, pageSize, properties, sort, queries, operator, cb) {
-		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
-
 		async.waterfall(
 			[
 				next => {
@@ -243,14 +241,17 @@ export default {
 									{
 										$addFields: {
 											hasPassword: {
-												$cond: [{ $eq: [{ $type: "$services.password.password" }, "string"] }, true, false]
+												$cond: [
+													{ $eq: [{ $type: "$services.password.password" }, "string"] },
+													true,
+													false
+												]
 											}
 										}
 									}
 								]
 							},
-							specialQueries: {
-							}
+							specialQueries: {}
 						},
 						this
 					)

+ 13 - 8
backend/logic/db/index.js

@@ -344,7 +344,9 @@ class _DBModule extends CoreClass {
 							return next("Unable to filter by blacklisted property.");
 						if (
 							Object.keys(sort).some(property =>
-								blacklistedProperties.some(blacklistedProperty => blacklistedProperty.startsWith(property))
+								blacklistedProperties.some(blacklistedProperty =>
+									blacklistedProperty.startsWith(property)
+								)
 							)
 						)
 							return next("Unable to sort by blacklisted property.");
@@ -361,7 +363,8 @@ class _DBModule extends CoreClass {
 							1,
 							([specialProperty, pipelineSteps], next) => {
 								// Check if a filter with the special property exists
-								const filterExists = queries.map(query => query.filter.property).indexOf(specialProperty) !== -1;
+								const filterExists =
+									queries.map(query => query.filter.property).indexOf(specialProperty) !== -1;
 								// Check if a property with the special property exists
 								const propertyExists = properties.indexOf(specialProperty) !== -1;
 								// If no such filter or property exists, skip this function
@@ -483,12 +486,14 @@ class _DBModule extends CoreClass {
 					(pipeline, next) => {
 						const { modelName } = payload;
 
-						DBModule.runJob("GET_MODEL", { modelName }, this).then(model => {
-							if (!model) return next("Invalid model.");
-							return next(null, pipeline, model);
-						}).catch(err => {
-							next(err);
-						});
+						DBModule.runJob("GET_MODEL", { modelName }, this)
+							.then(model => {
+								if (!model) return next("Invalid model.");
+								return next(null, pipeline, model);
+							})
+							.catch(err => {
+								next(err);
+							});
 					},
 
 					// Executes the aggregation pipeline