--- title: Klaxit trajets frauduleux tags: Debug --- # Statistiques Trajets Klaxit ## Nombre de trajets en `fraud_check = 'error'` ### Mois par mois ![](https://i.imgur.com/gopDzaw.png) ### Mois par mois par classes ![](https://i.imgur.com/TBP4ewB.png) :::info 2/3 en plus de trajets classe C globalement ::: :::warning Biais quand on compte sur Carpool ::: En comptant les numéros d'acquisition plutot un count(*) sur carpool : ![](https://i.imgur.com/SsDJebP.png) ### SQL ```sql SELECT oo.name as nom_opérateur, cc.operator_class, TO_CHAR(cc.datetime::DATE, 'yyyy-mm') as mois, COUNT(*) FROM carpool.carpools AS cc LEFT JOIN operator.operators AS oo ON oo._id = cc.operator_id WHERE cc.datetime >= (NOW() - '6 months'::interval) AND cc.status = 'fraudcheck_error' AND oo.name = 'Klaxit' GROUP BY oo.name,TO_CHAR(cc.datetime::DATE, 'yyyy-mm'), cc.operator_class ORDER BY TO_CHAR(cc.datetime::DATE, 'yyyy-mm') ASC; ``` ## Nombre de trajets incités RPC vs Klaxit ### En prenant en compte les trajets RPC avec incentive >= 0 ![](https://i.imgur.com/Z2EEeLj.png) ### En prenant en compte les trajets RPC avec incentive > 0 strictement ![](https://i.imgur.com/etgbns6.png) :::warning Gros delta quand on regarde uniquement les incitations > 0 coté RPC. Sachant que les opérateurs ne nous envoient jamais des incitations = 0 ::: Pour expliquer cet écart plusieurs posssibilités : * Les trajets en fraud_check error * Les trajets chez qui le conducteur a dépasser le plafond d'incitation ou de trajets journalier * Les trajets ont un point de départ ou d'arriver qui n'est pas compris dans la zone IDFM => Raison majeure de la différence :::info Cela implique forcément un très gros delta entre le total des incitations calculées par les opérateurs et le total RPC ::: ### En prenant en compte trajets IDFM avec incentive >= 0 ![](https://i.imgur.com/kBXoyPx.png) ### En prenant en compte trajets IDFM avec incentive > 0 ![](https://i.imgur.com/vtX4YRz.png) ### SQL ```sql SELECT to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text) AS month, COALESCE(sum(list.passenger_seats), 0::bigint)::integer AS trip, count(*) FILTER (WHERE (COALESCE(list.passenger_incentive_rpc_sum, 0) + COALESCE(list.driver_incentive_rpc_sum, 0)) > 0)::integer AS trip_subsidized_rpc, count(*) FILTER (WHERE array_to_string(list.driver_incentive_raw, ', '::text) ~~ '%incentive%'::text OR array_to_string(list.passenger_incentive_raw, ', '::text) ~~ '%incentive%'::text) AS trip_subsidized_operator FROM trip.list WHERE list.journey_start_datetime >= (now() - '5 months'::interval) AND operator_id = 3 GROUP BY (to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text)); ``` ## Nombre de trajet éligible RPC (incitation > ou = à 0) vs incité Klaxit (au moins une ligne d'incentive) ![](https://i.imgur.com/BSmhgW8.png) ### SQL ```sql SELECT to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text) AS month, COALESCE(sum(list.passenger_seats), 0::bigint)::integer AS trip, count(*) FILTER (WHERE list.passenger_incentive_rpc_sum >= 0 OR list.driver_incentive_rpc_sum >= 0) AS trip_eligible_rpc, count(*) FILTER (WHERE array_to_string(list.driver_incentive_raw, ', '::text) ~~ '%incentive%'::text OR array_to_string(list.passenger_incentive_raw, ', '::text) ~~ '%incentive%'::text) AS trip_subsidized_operator FROM trip.list WHERE list.journey_start_datetime >= (now() - '5 months'::interval) -- AND (journey_start_towngroup = 'Ile-De-France Mobilites' OR journey_end_towngroup = 'Ile-De-France Mobilites' OR applied_policies && ARRAY[459]) AND operator_id = 3 GROUP BY (to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text)); ``` ## Nombre de trajet éligible RPC pour IDFM (incitation > ou = à 0) vs incité Klaxit (au moins une ligne d'incentive) ![](https://i.imgur.com/ZkGZLEZ.png) ### SQL ```sql SELECT to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text) AS month, COALESCE(sum(list.passenger_seats), 0::bigint)::integer AS trip, count(*) FILTER (WHERE applied_policies && ARRAY[459]) AS trip_eligible_idfm_rpc, count(*) FILTER (WHERE array_to_string(list.driver_incentive_raw, ', '::text) ~~ '%incentive%'::text OR array_to_string(list.passenger_incentive_raw, ', '::text) ~~ '%incentive%'::text) AS trip_subsidized_operator FROM trip.list WHERE list.journey_start_datetime >= (now() - '5 months'::interval) -- AND (journey_start_towngroup = 'Ile-De-France Mobilites' OR journey_end_towngroup = 'Ile-De-France Mobilites' OR) AND operator_id = 3 GROUP BY (to_char(list.journey_start_datetime::date::timestamp with time zone, 'yyyy-mm'::text)); ``` # Détail cas par cas ## Cas 1 ### Un passager se retrouve dans 2 trajets différents, environ à la même heure mais avec des lieux de départs différents 8c26b640-db03-439e-a2ba-fb883c702720 (+336273746) est passager pour 2 trajets : journey_id 389eced8-3369-41ea-90e2-d415d90dcede Départ de Fontenay-Le-Compte à 21h24 Duration = 4428 (~73min ) Arrivé à La Rochelle (~22h37) journey_id 0da1f88d-b2a8-4c21-b9ae-fbbbb524ce99 Départ de Niort à 20H29 Duration = 4237 (~70min) Arrivé à La Rochelle à (~21H40) :::warning Il n'est pas possible d'être à La Rochelle à 21H40 et Fontenay Le compte à 21H24 car les 2 sont séparés de 56km (~1h) ::: ![](https://i.imgur.com/OKBorze.png) ## Cas 2 ### Un passager se retrouve dans 2 trajets différents à une même date mais pour des déstinations différentes 9e6030f4-2375-4ae3-b385-09376e51ce53 (+336671471) est passager pour un trajet (operator_journey_id 8154cc7c-893d-4dea-866c-707dbd6043ca ) Beauvais -> Crois-Moligneaux (115 km) partant à 2022-04-25 18:27:15+00 9e6030f4-2375-4ae3-b385-09376e51ce53 (+336671471) est passager pour un trajet (operator_journey_id c3234015-5064-4e9b-92dd-3427a86cdbd0 ) Beauvais -> Haudainville (350 km) partant à 2022-04-25 18:31:24+00 :::warning La personne fait partie de 2 trajets différents en même temps ::: ## Cas 3 ### Une personne est en même temps conducteur et passager pour 2 trajets se réalisant à une même date 89ce286b-8d92-46fe-a040-b7ea5b8cae94 (+336332822) est conducteur pour un trajet (operator_journey_id c3234015-5064-4e9b-92dd-3427a86cdbd0) Beauvais ->Haudainville (350km) partant à 2022-04-25 17:36:38+00 et d'une durée de 4h30 (operator_journey_id 8154cc7c-893d-4dea-866c-707dbd6043ca) 89ce286b-8d92-46fe-a040-b7ea5b8cae94 (+336332822) est passager pour un trajet (operator_journey_id 8154cc7c-893d-4dea-866c-707dbd6043ca) Beauvais -> Croix-Moligneaux (115km) partant à 2022-04-25 18:28:47+00 et une durée de 1h30 :::warning La personne ne peut pas, à la fois, partir de Beauvais en tant que conducteur à 17H36 de Beauvais et en tant que passager à 18H30 toujours de Beauvais ::: ![](https://i.imgur.com/w8QV4dw.png)