musora-content-services 1.0.200 → 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 CHANGED
@@ -2,6 +2,8 @@
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
+
5
7
  ### [1.0.200](https://github.com/railroadmedia/musora-content-services/compare/v1.0.199...v1.0.200) (2024-11-29)
6
8
 
7
9
  ### [1.0.199](https://github.com/railroadmedia/musora-content-services/compare/v1.0.198...v1.0.199) (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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.200",
3
+ "version": "1.0.201",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -97,7 +97,17 @@ export class FilterBuilder {
97
97
 
98
98
  _applyPublishingDateRestrictions() {
99
99
  if(this.bypassPublishedDateRestriction) return this;
100
- const now = new Date().toISOString();
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) {
File without changes
File without changes
File without changes
@@ -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
File without changes
File without changes
File without changes
package/test/log.js CHANGED
File without changes
File without changes
File without changes