@tmlmobilidade/interfaces 20260605.149.34 → 20260605.1145.54
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, UnixTimestamp } from '@tmlmobilidade/types';
|
|
2
|
+
import { DelayStatus, 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
|
*
|
|
@@ -48,6 +48,11 @@ export declare function ridesPipelineOperationalStatus({ filter }?: {
|
|
|
48
48
|
operational_status?: OperationalStatus[];
|
|
49
49
|
};
|
|
50
50
|
}): AggregationPipeline<Ride>;
|
|
51
|
+
export declare function ridesPipelineticketingStatus({ filter }?: {
|
|
52
|
+
filter?: {
|
|
53
|
+
ticketing_status?: TicketingStatus[];
|
|
54
|
+
};
|
|
55
|
+
}): AggregationPipeline<Ride>;
|
|
51
56
|
/**
|
|
52
57
|
* Creates MongoDB aggregation pipeline stages to calculate and categorize seen statuses.
|
|
53
58
|
*
|
|
@@ -73,6 +78,11 @@ export declare function ridesPipelineSeenStatus({ filter }?: {
|
|
|
73
78
|
seen_status?: SeenStatus[];
|
|
74
79
|
};
|
|
75
80
|
}): AggregationPipeline<Ride>;
|
|
81
|
+
export declare function ridePipelineTicketingStatus({ filter }?: {
|
|
82
|
+
filter?: {
|
|
83
|
+
ticketing_status?: TicketingStatus[];
|
|
84
|
+
};
|
|
85
|
+
}): AggregationPipeline<Ride>;
|
|
76
86
|
interface RidesPipelineFilter {
|
|
77
87
|
acceptance_status?: ('none' | RideAcceptanceStatus)[];
|
|
78
88
|
agency_ids?: string[];
|
|
@@ -88,6 +98,7 @@ interface RidesPipelineFilter {
|
|
|
88
98
|
search?: string;
|
|
89
99
|
seen_statuses?: SeenStatus[];
|
|
90
100
|
stop_ids?: string[];
|
|
101
|
+
ticketing_status?: TicketingStatus[];
|
|
91
102
|
}
|
|
92
103
|
/**
|
|
93
104
|
* Creates MongoDB aggregation pipeline stages to filter and process ride data.
|
|
@@ -195,6 +195,22 @@ export function ridesPipelineOperationalStatus({ filter } = {}) {
|
|
|
195
195
|
}
|
|
196
196
|
return pipeline;
|
|
197
197
|
}
|
|
198
|
+
export function ridesPipelineticketingStatus({ filter } = {}) {
|
|
199
|
+
const pipeline = [];
|
|
200
|
+
if (filter?.ticketing_status?.length)
|
|
201
|
+
return pipeline;
|
|
202
|
+
const includesHasTicketing = filter.ticketing_status.includes('has_ticketing');
|
|
203
|
+
const includesNoTicketing = filter.ticketing_status.includes('no_ticketing');
|
|
204
|
+
if (includesHasTicketing && !includesNoTicketing)
|
|
205
|
+
return pipeline;
|
|
206
|
+
if (includesHasTicketing) {
|
|
207
|
+
pipeline.push({ $match: { apex_validations_qty: { $gte: 1 } } });
|
|
208
|
+
}
|
|
209
|
+
if (includesNoTicketing) {
|
|
210
|
+
pipeline.push({ $match: { apex_validations_qty: { $eq: 0 } } });
|
|
211
|
+
}
|
|
212
|
+
return pipeline;
|
|
213
|
+
}
|
|
198
214
|
/**
|
|
199
215
|
* Creates MongoDB aggregation pipeline stages to calculate and categorize seen statuses.
|
|
200
216
|
*
|
|
@@ -262,6 +278,38 @@ export function ridesPipelineSeenStatus({ filter } = {}) {
|
|
|
262
278
|
}
|
|
263
279
|
return pipeline;
|
|
264
280
|
}
|
|
281
|
+
export function ridePipelineTicketingStatus({ filter } = {}) {
|
|
282
|
+
if (!filter?.ticketing_status?.length) {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
const pipeline = [
|
|
286
|
+
{
|
|
287
|
+
$addFields: {
|
|
288
|
+
ticketing_status: {
|
|
289
|
+
$cond: {
|
|
290
|
+
else: 'no_ticketing',
|
|
291
|
+
if: {
|
|
292
|
+
$and: [
|
|
293
|
+
{ $ifNull: ['$apex_validations_qty', false] },
|
|
294
|
+
{ $gt: ['$apex_validations_qty', 0] },
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
then: 'has_ticketing',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
$match: {
|
|
304
|
+
ticketing_status: { $in: filter.ticketing_status },
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
$project: { ticketing_status: 0 },
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
return pipeline;
|
|
312
|
+
}
|
|
265
313
|
/**
|
|
266
314
|
* Attempts to map search term to specific indexed field based on structural
|
|
267
315
|
* heuristics. Returns null when term does not match known pattern.
|
|
@@ -448,5 +496,6 @@ export function ridesBatchAggregationPipeline({ ...filter }) {
|
|
|
448
496
|
pipeline.push(...ridesPipelineDelayStatus({ filter: { end_delay_status: filter.delay_statuses, start_delay_status: filter.delay_statuses } }));
|
|
449
497
|
pipeline.push(...ridesPipelineOperationalStatus({ filter: { operational_status: filter.operational_statuses } }));
|
|
450
498
|
pipeline.push(...ridesPipelineSeenStatus({ filter: { seen_status: filter.seen_statuses } }));
|
|
499
|
+
pipeline.push(...ridePipelineTicketingStatus({ filter: { ticketing_status: filter.ticketing_status } }));
|
|
451
500
|
return pipeline;
|
|
452
501
|
}
|