-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1503 from betagouv/hotfix/hydrate-field-order
[Hotfix] hydrate field order
- Loading branch information
Showing
6 changed files
with
264 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
var { createMigration } = require('../helpers/createMigration'); | ||
var { setup, up, down } = createMigration(['trip/20210923075129_fix_hydrate_trip_fn'], __dirname); | ||
|
||
exports.setup = setup; | ||
exports.up = up; | ||
exports.down = down; |
1 change: 1 addition & 0 deletions
1
api/db/migrations/trip/20210923075129_fix_hydrate_trip_fn.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- NOTHING TO DO |
226 changes: 226 additions & 0 deletions
226
api/db/migrations/trip/20210923075129_fix_hydrate_trip_fn.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
CREATE OR REPLACE FUNCTION hydrate_trip_from_carpool() RETURNS TRIGGER AS $$ | ||
BEGIN | ||
INSERT INTO trip.list ( | ||
operator_id, | ||
start_territory_id, | ||
end_territory_id, | ||
applied_policies, | ||
journey_id, | ||
trip_id, | ||
journey_start_datetime, | ||
journey_start_weekday, | ||
journey_start_dayhour, | ||
journey_start_lon, | ||
journey_start_lat, | ||
journey_start_insee, | ||
journey_start_postalcode, | ||
journey_start_department, | ||
journey_start_town, | ||
journey_start_towngroup, | ||
journey_start_country, | ||
journey_end_datetime, | ||
journey_end_lon, | ||
journey_end_lat, | ||
journey_end_insee, | ||
journey_end_postalcode, | ||
journey_end_department, | ||
journey_end_town, | ||
journey_end_towngroup, | ||
journey_end_country, | ||
journey_distance, | ||
journey_distance_anounced, | ||
journey_distance_calculated, | ||
journey_duration, | ||
journey_duration_anounced, | ||
journey_duration_calculated, | ||
operator, | ||
operator_class, | ||
operator_journey_id, | ||
operator_passenger_id, | ||
operator_driver_id, | ||
passenger_id, | ||
passenger_card, | ||
passenger_over_18, | ||
passenger_seats, | ||
passenger_contribution, | ||
passenger_incentive_raw, | ||
passenger_incentive_rpc_raw, | ||
passenger_incentive_rpc_sum, | ||
passenger_incentive_rpc_financial_sum, | ||
driver_id, | ||
driver_card, | ||
driver_revenue, | ||
driver_incentive_raw, | ||
driver_incentive_rpc_raw, | ||
driver_incentive_rpc_sum, | ||
driver_incentive_rpc_financial_sum, | ||
status | ||
) SELECT | ||
operator_id, | ||
start_territory_id, | ||
end_territory_id, | ||
applied_policies, | ||
journey_id, | ||
trip_id, | ||
journey_start_datetime, | ||
journey_start_weekday, | ||
journey_start_dayhour, | ||
journey_start_lon, | ||
journey_start_lat, | ||
journey_start_insee, | ||
journey_start_postalcode, | ||
journey_start_department, | ||
journey_start_town, | ||
journey_start_towngroup, | ||
journey_start_country, | ||
journey_end_datetime, | ||
journey_end_lon, | ||
journey_end_lat, | ||
journey_end_insee, | ||
journey_end_postalcode, | ||
journey_end_department, | ||
journey_end_town, | ||
journey_end_towngroup, | ||
journey_end_country, | ||
journey_distance, | ||
journey_distance_anounced, | ||
journey_distance_calculated, | ||
journey_duration, | ||
journey_duration_anounced, | ||
journey_duration_calculated, | ||
operator, | ||
operator_class, | ||
operator_journey_id, | ||
operator_passenger_id, | ||
operator_driver_id, | ||
passenger_id, | ||
passenger_card, | ||
passenger_over_18, | ||
passenger_seats, | ||
passenger_contribution, | ||
passenger_incentive_raw, | ||
passenger_incentive_rpc_raw, | ||
passenger_incentive_rpc_sum, | ||
passenger_incentive_rpc_financial_sum, | ||
driver_id, | ||
driver_card, | ||
driver_revenue, | ||
driver_incentive_raw, | ||
driver_incentive_rpc_raw, | ||
driver_incentive_rpc_sum, | ||
driver_incentive_rpc_financial_sum, | ||
status | ||
FROM trip.list_view WHERE journey_id = NEW.acquisition_id | ||
ON CONFLICT (journey_id) | ||
DO UPDATE SET ( | ||
operator_id, | ||
start_territory_id, | ||
end_territory_id, | ||
applied_policies, | ||
trip_id, | ||
journey_start_datetime, | ||
journey_start_weekday, | ||
journey_start_dayhour, | ||
journey_start_lon, | ||
journey_start_lat, | ||
journey_start_insee, | ||
journey_start_postalcode, | ||
journey_start_department, | ||
journey_start_town, | ||
journey_start_towngroup, | ||
journey_start_country, | ||
journey_end_datetime, | ||
journey_end_lon, | ||
journey_end_lat, | ||
journey_end_insee, | ||
journey_end_postalcode, | ||
journey_end_department, | ||
journey_end_town, | ||
journey_end_towngroup, | ||
journey_end_country, | ||
journey_distance, | ||
journey_distance_anounced, | ||
journey_distance_calculated, | ||
journey_duration, | ||
journey_duration_anounced, | ||
journey_duration_calculated, | ||
operator, | ||
operator_class, | ||
operator_journey_id, | ||
operator_passenger_id, | ||
operator_driver_id, | ||
passenger_id, | ||
passenger_card, | ||
passenger_over_18, | ||
passenger_seats, | ||
passenger_contribution, | ||
passenger_incentive_raw, | ||
passenger_incentive_rpc_raw, | ||
passenger_incentive_rpc_sum, | ||
passenger_incentive_rpc_financial_sum, | ||
driver_id, | ||
driver_card, | ||
driver_revenue, | ||
driver_incentive_raw, | ||
driver_incentive_rpc_raw, | ||
driver_incentive_rpc_sum, | ||
driver_incentive_rpc_financial_sum, | ||
status | ||
) = ( | ||
excluded.operator_id, | ||
excluded.start_territory_id, | ||
excluded.end_territory_id, | ||
excluded.applied_policies, | ||
excluded.trip_id, | ||
excluded.journey_start_datetime, | ||
excluded.journey_start_weekday, | ||
excluded.journey_start_dayhour, | ||
excluded.journey_start_lon, | ||
excluded.journey_start_lat, | ||
excluded.journey_start_insee, | ||
excluded.journey_start_postalcode, | ||
excluded.journey_start_department, | ||
excluded.journey_start_town, | ||
excluded.journey_start_towngroup, | ||
excluded.journey_start_country, | ||
excluded.journey_end_datetime, | ||
excluded.journey_end_lon, | ||
excluded.journey_end_lat, | ||
excluded.journey_end_insee, | ||
excluded.journey_end_postalcode, | ||
excluded.journey_end_department, | ||
excluded.journey_end_town, | ||
excluded.journey_end_towngroup, | ||
excluded.journey_end_country, | ||
excluded.journey_distance, | ||
excluded.journey_distance_anounced, | ||
excluded.journey_distance_calculated, | ||
excluded.journey_duration, | ||
excluded.journey_duration_anounced, | ||
excluded.journey_duration_calculated, | ||
excluded.operator, | ||
excluded.operator_class, | ||
excluded.operator_journey_id, | ||
excluded.operator_passenger_id, | ||
excluded.operator_driver_id, | ||
excluded.passenger_id, | ||
excluded.passenger_card, | ||
excluded.passenger_over_18, | ||
excluded.passenger_seats, | ||
excluded.passenger_contribution, | ||
excluded.passenger_incentive_raw, | ||
excluded.passenger_incentive_rpc_raw, | ||
excluded.passenger_incentive_rpc_sum, | ||
excluded.passenger_incentive_rpc_financial_sum, | ||
excluded.driver_id, | ||
excluded.driver_card, | ||
excluded.driver_revenue, | ||
excluded.driver_incentive_raw, | ||
excluded.driver_incentive_rpc_raw, | ||
excluded.driver_incentive_rpc_sum, | ||
excluded.driver_incentive_rpc_financial_sum, | ||
excluded.status | ||
); | ||
RETURN NULL; | ||
END; | ||
$$ language plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters