@tmlmobilidade/interfaces 20260706.1839.32 → 20260707.1036.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregationPipeline } from '../../common/aggregation-pipeline.js';
|
|
2
|
-
import { DelayStatus, OperationalStatus, Ride, RideAcceptanceStatus, RideAnalysisGradeWithNone, SeenStatus, TicketingStatus, UnixTimestamp } from '@tmlmobilidade/types';
|
|
2
|
+
import { DelayStatus, OneOrTheOther, OperationalDate, OperationalStatus, Ride, RideAcceptanceStatus, RideAnalysisGradeWithNone, SeenStatus, TicketingStatus, UnixTimestamp } from '@tmlmobilidade/types';
|
|
3
3
|
/**
|
|
4
4
|
* Creates MongoDB aggregation pipeline stages to calculate and categorize delay statuses.
|
|
5
5
|
*
|
|
@@ -78,23 +78,31 @@ export declare function ridesPipelineTicketingStatus({ filter }?: {
|
|
|
78
78
|
ticketing_status?: TicketingStatus[];
|
|
79
79
|
};
|
|
80
80
|
}): AggregationPipeline<Ride>;
|
|
81
|
-
interface
|
|
81
|
+
interface DatesRange {
|
|
82
|
+
date_end: UnixTimestamp;
|
|
83
|
+
date_start: UnixTimestamp;
|
|
84
|
+
}
|
|
85
|
+
interface OperationalDateRange {
|
|
86
|
+
operational_date_end: OperationalDate;
|
|
87
|
+
operational_date_start: OperationalDate;
|
|
88
|
+
}
|
|
89
|
+
type RidesPipelineFilter = OneOrTheOther<DatesRange, OperationalDateRange> & {
|
|
82
90
|
acceptance_status?: ('none' | RideAcceptanceStatus)[];
|
|
83
91
|
agency_ids?: string[];
|
|
84
92
|
analysis_ended_at_last_stop_grade?: RideAnalysisGradeWithNone[];
|
|
85
93
|
analysis_expected_apex_validation_interval?: RideAnalysisGradeWithNone[];
|
|
86
94
|
analysis_simple_three_vehicle_events_grade?: RideAnalysisGradeWithNone[];
|
|
87
95
|
analysis_transaction_sequentiality?: RideAnalysisGradeWithNone[];
|
|
88
|
-
date_end: UnixTimestamp;
|
|
89
|
-
date_start: UnixTimestamp;
|
|
90
96
|
delay_statuses?: DelayStatus[];
|
|
91
97
|
line_ids?: string[];
|
|
92
98
|
operational_statuses?: OperationalStatus[];
|
|
99
|
+
pattern_ids?: string[];
|
|
93
100
|
search?: string;
|
|
94
101
|
seen_statuses?: SeenStatus[];
|
|
95
102
|
stop_ids?: string[];
|
|
96
103
|
ticketing_status?: TicketingStatus[];
|
|
97
|
-
|
|
104
|
+
vehicle_ids?: number[];
|
|
105
|
+
};
|
|
98
106
|
/**
|
|
99
107
|
* Creates MongoDB aggregation pipeline stages to filter and process ride data.
|
|
100
108
|
*
|
|
@@ -405,7 +405,15 @@ function buildSearchPipeline(filter) {
|
|
|
405
405
|
export function ridesBatchAggregationPipeline({ ...filter }) {
|
|
406
406
|
const pipeline = [];
|
|
407
407
|
// Stage 1: Filter by scheduled time range (required)
|
|
408
|
-
|
|
408
|
+
if ('date_start' in filter && 'date_end' in filter) {
|
|
409
|
+
pipeline.push({ $match: { start_time_scheduled: { $gte: filter.date_start, $lte: filter.date_end } } });
|
|
410
|
+
}
|
|
411
|
+
else if ('operational_date_start' in filter && 'operational_date_end' in filter) {
|
|
412
|
+
pipeline.push({ $match: { operational_date: { $gte: filter.operational_date_start, $lte: filter.operational_date_end } } });
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
throw new Error('Either date_start and date_end or operational_date_start and operational_date_end must be provided');
|
|
416
|
+
}
|
|
409
417
|
// Stage 2: Filter by agency IDs (required)
|
|
410
418
|
pipeline.push({ $match: { agency_id: { $in: filter.agency_ids ?? [] } } });
|
|
411
419
|
// Stage 2.1: Sort by start_time_scheduled
|