@@ -22,7 +22,8 @@ class Station extends Model {
2222 */
2323 static async getAll ( perms , args , { isMad, hasStationedGmax } ) {
2424 const { areaRestrictions } = perms
25- const { stationUpdateLimit } = config . getSafe ( 'api' )
25+ const { stationUpdateLimit, stationInactiveLimitDays } =
26+ config . getSafe ( 'api' )
2627 const {
2728 onlyAreas,
2829 onlyAllStations,
@@ -55,7 +56,9 @@ class Station extends Model {
5556 maxLon : args . maxLon ,
5657 } ,
5758 } )
58- const activeCutoff = Date . now ( ) / 1000 - stationUpdateLimit * 60 * 60
59+ const now = Date . now ( ) / 1000
60+ const activeCutoff = now - stationUpdateLimit * 60 * 60
61+ const inactiveCutoff = now - stationInactiveLimitDays * 24 * 60 * 60
5962
6063 if ( onlyInactiveStations ) {
6164 query . andWhere ( ( builder ) => {
@@ -65,7 +68,11 @@ class Station extends Model {
6568 . where ( 'end_time' , '>' , ts )
6669 . andWhere ( 'updated' , '>' , activeCutoff ) ,
6770 )
68- . orWhere ( 'end_time' , '<=' , ts )
71+ . orWhere ( ( inactive ) =>
72+ inactive
73+ . where ( 'end_time' , '<=' , ts )
74+ . andWhere ( 'updated' , '>' , inactiveCutoff ) ,
75+ )
6976 } )
7077 } else {
7178 query . andWhere ( 'end_time' , '>' , ts ) . andWhere ( 'updated' , '>' , activeCutoff )
0 commit comments