Browse Source

fix: stationHistoryModel undefined

Owen Diffey 1 year ago
parent
commit
776cb83463
2 changed files with 5 additions and 2 deletions
  1. 2 1
      backend/logic/actions/stations.js
  2. 3 1
      backend/logic/stations.js

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

@@ -1037,7 +1037,8 @@ export default {
 				},
 
 				async () => {
-					const response = await StationsModule.stationHistoryModel
+					const stationHistoryModel = await DBModule.runJob("GET_MODEL", { modelName: "stationHistory" });
+					const response = await stationHistoryModel
 						.find({ stationId }, { documentVersion: 0, __v: 0 })
 						.sort({ "payload.skippedAt": -1 })
 						.limit(250);

+ 3 - 1
backend/logic/stations.js

@@ -987,7 +987,9 @@ class _StationsModule extends CoreClass {
 
 		const { stationId, currentSong, skipReason, skippedAt } = payload;
 
-		let document = await StationsModule.stationHistoryModel.create({
+		const stationHistoryModel = await DBModule.runJob("GET_MODEL", { modelName: "stationHistory" });
+
+		let document = await stationHistoryModel.create({
 			stationId,
 			type: "song_played",
 			payload: {