| 1876 | } |
| 1877 | |
| 1878 | _setTimeOptions() { |
| 1879 | // NOTE: EXPIRE_ONE_DAY_EARLIER and TRANSITION_ONE_DAY_EARLIER are deprecated in favor of |
| 1880 | // TIME_PROGRESSION_FACTOR which decreases the weight attributed to a day in order to among other things |
| 1881 | // expedite the lifecycle of objects. |
| 1882 | |
| 1883 | // moves lifecycle expiration deadlines 1 day earlier, mostly for testing |
| 1884 | const expireOneDayEarlier = process.env.EXPIRE_ONE_DAY_EARLIER === 'true'; |
| 1885 | // moves lifecycle transition deadlines 1 day earlier, mostly for testing |
| 1886 | const transitionOneDayEarlier = process.env.TRANSITION_ONE_DAY_EARLIER === 'true'; |
| 1887 | // decreases the weight attributed to a day in order to expedite the lifecycle of objects. |
| 1888 | const timeProgressionFactor = Number.parseInt(process.env.TIME_PROGRESSION_FACTOR, 10) || 1; |
| 1889 | |
| 1890 | const isIncompatible = (expireOneDayEarlier || transitionOneDayEarlier) && (timeProgressionFactor > 1); |
| 1891 | assert(!isIncompatible, 'The environment variables "EXPIRE_ONE_DAY_EARLIER" or ' + |
| 1892 | '"TRANSITION_ONE_DAY_EARLIER" are not compatible with the "TIME_PROGRESSION_FACTOR" variable.'); |
| 1893 | |
| 1894 | // The scaledMsPerDay value is initially set to the number of milliseconds per day |
| 1895 | // (24 * 60 * 60 * 1000) as the default value. |
| 1896 | // However, during testing, if the timeProgressionFactor is defined and greater than 1, |
| 1897 | // the scaledMsPerDay value is decreased. This adjustment allows for simulating actions occurring |
| 1898 | // earlier in time. |
| 1899 | const scaledMsPerDay = scaleMsPerDay(timeProgressionFactor); |
| 1900 | |
| 1901 | this.timeOptions = { |
| 1902 | expireOneDayEarlier, |
| 1903 | transitionOneDayEarlier, |
| 1904 | timeProgressionFactor, |
| 1905 | scaledMsPerDay, |
| 1906 | }; |
| 1907 | } |
| 1908 | |
| 1909 | getTimeOptions() { |
| 1910 | return this.timeOptions; |