musora-content-services 1.0.199 → 1.0.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +0 -0
- package/jest.config.js +0 -0
- package/link_mcs.sh +3 -0
- package/package.json +1 -1
- package/src/filterBuilder.js +11 -1
- package/src/services/config.js +0 -0
- package/src/services/contentLikes.js +0 -0
- package/src/services/lastUpdated.js +0 -0
- package/src/services/sanity.js +14 -3
- package/src/services/userPermissions.js +0 -0
- package/test/contentLikes.test.js +0 -0
- package/test/initializeTests.js +0 -0
- package/test/lastUpdated.test.js +0 -0
- package/test/localStorageMock.js +0 -0
- package/test/log.js +0 -0
- package/test/userPermissions.test.js +0 -0
- package/tools/generate-index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.201](https://github.com/railroadmedia/musora-content-services/compare/v1.0.200...v1.0.201) (2024-11-29)
|
|
6
|
+
|
|
7
|
+
### [1.0.200](https://github.com/railroadmedia/musora-content-services/compare/v1.0.199...v1.0.200) (2024-11-29)
|
|
8
|
+
|
|
5
9
|
### [1.0.199](https://github.com/railroadmedia/musora-content-services/compare/v1.0.198...v1.0.199) (2024-11-29)
|
|
6
10
|
|
|
7
11
|
### [1.0.198](https://github.com/railroadmedia/musora-content-services/compare/v1.0.185...v1.0.198) (2024-11-29)
|
package/README.md
CHANGED
|
File without changes
|
package/jest.config.js
CHANGED
|
File without changes
|
package/link_mcs.sh
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# If this is giving you errors when trying to build on MWP after linking, try the more modern linking method of running
|
|
4
|
+
# "yarn link ../musora-content-services/" from the MWP directory.
|
|
5
|
+
|
|
3
6
|
# Define the paths (edit these paths according to your directory structure)
|
|
4
7
|
MUSORA_CONTENT_SERVICES_DIR="../musora-content-services"
|
|
5
8
|
MUSORA_WEB_PLATFORM_DIR="../musora-web-platform"
|
package/package.json
CHANGED
package/src/filterBuilder.js
CHANGED
|
@@ -97,7 +97,17 @@ export class FilterBuilder {
|
|
|
97
97
|
|
|
98
98
|
_applyPublishingDateRestrictions() {
|
|
99
99
|
if(this.bypassPublishedDateRestriction) return this;
|
|
100
|
-
|
|
100
|
+
let now = new Date();
|
|
101
|
+
|
|
102
|
+
// We need to set the published on filter date to be a round time so that it doesn't bypass the query cache
|
|
103
|
+
// with every request by changing the filter date every second. I've set it to one minute past the current hour
|
|
104
|
+
// because publishing usually publishes content on the hour exactly which means it should still skip the cache
|
|
105
|
+
// when the new content is available.
|
|
106
|
+
// Round to the start of the current hour
|
|
107
|
+
const roundedDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours());
|
|
108
|
+
|
|
109
|
+
now = roundedDate.toISOString();
|
|
110
|
+
|
|
101
111
|
if (this.getFutureContentOnly) {
|
|
102
112
|
this._andWhere(`published_on >= '${now}'`);
|
|
103
113
|
} else if (!this.pullFutureContent) {
|
package/src/services/config.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/services/sanity.js
CHANGED
|
@@ -755,7 +755,7 @@ export function getSortOrder(sort = '-published_on', brand, groupBy) {
|
|
|
755
755
|
sortOrder = sort;
|
|
756
756
|
break;
|
|
757
757
|
case "popularity":
|
|
758
|
-
if (groupBy == "artist" || groupBy == "") {
|
|
758
|
+
if (groupBy == "artist" || groupBy == "genre") {
|
|
759
759
|
sortOrder = isDesc ? `coalesce(popularity.${brand}, -1)` : "popularity";
|
|
760
760
|
} else {
|
|
761
761
|
sortOrder = isDesc ? "coalesce(popularity, -1)" : "popularity";
|
|
@@ -1261,7 +1261,7 @@ export async function fetchLiveEvent(brand) {
|
|
|
1261
1261
|
// See LiveStreamEventService.getCurrentOrNextLiveEvent for some nice complicated logic which I don't think is actually importart
|
|
1262
1262
|
// this has some +- on times
|
|
1263
1263
|
// But this query just finds the first scheduled event (sorted by start_time) that ends after now()
|
|
1264
|
-
const query = `*[status == 'scheduled' && defined(live_event_start_time) && published_on > '${getSanityDate(dateTemp)}' && live_event_end_time >= '${getSanityDate(new Date())}']{
|
|
1264
|
+
const query = `*[status == 'scheduled' && defined(live_event_start_time) && published_on > '${getSanityDate(dateTemp, false)}' && live_event_end_time >= '${getSanityDate(new Date(), false)}']{
|
|
1265
1265
|
'slug': slug.current,
|
|
1266
1266
|
'id': railcontent_id,
|
|
1267
1267
|
live_event_start_time,
|
|
@@ -1879,7 +1879,18 @@ function arrayJoinWithQuotes(array, delimiter = ',') {
|
|
|
1879
1879
|
return wrapped.join(delimiter)
|
|
1880
1880
|
}
|
|
1881
1881
|
|
|
1882
|
-
function getSanityDate(date) {
|
|
1882
|
+
function getSanityDate(date, roundToHourForCaching = true) {
|
|
1883
|
+
if (roundToHourForCaching) {
|
|
1884
|
+
// We need to set the published on filter date to be a round time so that it doesn't bypass the query cache
|
|
1885
|
+
// with every request by changing the filter date every second. I've set it to one minute past the current hour
|
|
1886
|
+
// because publishing usually publishes content on the hour exactly which means it should still skip the cache
|
|
1887
|
+
// when the new content is available.
|
|
1888
|
+
// Round to the start of the current hour
|
|
1889
|
+
const roundedDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
|
|
1890
|
+
|
|
1891
|
+
return roundedDate.toISOString();
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1883
1894
|
return date.toISOString();
|
|
1884
1895
|
}
|
|
1885
1896
|
|
|
File without changes
|
|
File without changes
|
package/test/initializeTests.js
CHANGED
|
File without changes
|
package/test/lastUpdated.test.js
CHANGED
|
File without changes
|
package/test/localStorageMock.js
CHANGED
|
File without changes
|
package/test/log.js
CHANGED
|
File without changes
|
|
File without changes
|
package/tools/generate-index.js
CHANGED
|
File without changes
|