aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette
AgeCommit message (Collapse)Author
2018-04-16Route: Change `#calculate_costs!` to `after_commit` callbackTeddy Wing
Use an `after_commit` instead of an `after_save`. The `after_save` could cause intermittent problems due to Sidekiq starting before the record/transaction actually gets committed to the database. In those cases, the record wouldn't be found and cause an error. With an `after_commit` callback, the record is sure to be committed before Sidekiq takes over. Additionally, limit the callback to `:create` and `:update` because otherwise it will be active on `:destroy` by default also. This work isn't relevant on destroy, so don't do it then. Update the tests: * Update labels * Use `build` instead of `create` because we're saving the record at the end anyway so we don't need an object that starts out persisted * Use `truncation: true` for these tests because otherwise the `commit` callback doesn't get called due to transactional teardown Refs #6407
2018-04-12Refs #6527; Fix VJs editor6527-fix-vjs-editorZog
2018-04-11Merge pull request #467 from af83/fix-duplicate-positions-in-routesteddywing
Add a sentinel in dev mode to help capture the "double positions" bug
2018-04-11Refs #6493; Sort StopAreas on the type label, instead of the internal keyZog
2018-04-11Add a sentinel in dev mode to help capture the "double positions" bugZog
2018-04-10Merge pull request #438 from af83/6368-gtfs-importLuc Donnet
GTFS import (first step)
2018-04-09Refs #6367; Add metadata to other versioned modelsZog
2018-04-09Refs #6367; Add metadata to routesZog
2018-04-05Merge pull request #412 from af83/6217-extrapolate-border-passing-timesLuc Donnet
6217 Add a method to fill blanks in journeys passing times
2018-04-04Merge pull request #390 from af83/6226-create-opposite-routeLuc Donnet
6226 Add a button to automatically create opposite routes
2018-04-04Refs 6226; Add a button to create opposite routesZog
2018-04-04Refs #6196; Add Custom Fields to companiesZog
2018-04-04Refs #6090; CustomFields inputs made easyZog
:warning: We'll have to refine this code once StopArea are linked to workgroups
2018-04-03Merge pull request #437 from ↵Luc Donnet
af83/6387-default-values-for-stop-point-alighting-boarding 6387 Default for enumerizes :for_boarding and :for_alighting
2018-04-03Remove hardcoded format on line/stop_area/company registration_numbers ↵Alban Peignier
(blocks GTFS imports). Refs #6368
2018-04-03Refs #5972; Error messages more human-friendlyZog
2018-04-03Refs #5972; Don't assign a Registration Number in the formZog
This can cause a bug when several forms are opened concurently
2018-04-03Set default for enumerizes :for_boarding and :for_alighting. Refs #63876387-default-values-for-stop-point-alighting-boardingAlban Peignier
2018-03-29Refs #4658; Remove `current_functional_scope`Zog
2018-03-29Refs #6075 Replace after_commit callback to after_create for the ↵cedricnjanga
set_defaults method
2018-03-29Refs #6075 Change default attributes for stop areascedricnjanga
2018-03-29Refs #6075 Set defaults attributes for stop point depending on stop area kindcedricnjanga
2018-03-26Refs #6217; Add a method to fill blanks in journeys passing timesZog
When a passing time at a border can be extrapolated from other values.
2018-03-23Refs #6218; UI for exportsZog
2018-03-23Fix i18n enhancements on titles @3Luc Donnet
2018-03-23Refs #6210 Remove status value attribue from Chouette::VehicleJourney and ↵cedricnjanga
section status fron Chouette::JourneyPattern
2018-03-23Fix stop_area state for filter and display. Update reflex sync to use ↵Luc Donnet
confirmed_at. Refs #6141
2018-03-23Route: Don't run `#calculate_costs!` on callback if TomTom disabledTeddy Wing
We say `TomTom` is disabled when no API key is present. If this is the case, the `after_save` callback that uses it shouldn't be executed. I had to change my `API_KEY` constant to an instance variable to be able to change it for testing. Refs #6095
2018-03-23Route#duplicate: Use `#slice!` instead of `#slice`Teddy Wing
Johan suggested simplifying this method by changing the `slice` call: http://api.rubyonrails.org/classes/Hash.html#method-i-slice-21 I had modified this to fix the whitespace while working on the `WayCost` calculation function for `Chouette::Route`s, so don't really have a brain cache hit on this code, but the change makes sense and seems to work. Refs #6095
2018-03-23RouteWayCostWorker: Switch to referential in order to find RouteTeddy Wing
Just running `Chouette::Route.find(id)` doesn't give us anything if we don't have a `Referential` selected. In order to properly get the correct route, pass the referential ID to the worker and switch to that referential before trying to select the route. Refs #6095
2018-03-23Route: Run `#calculate_costs!` on `after_save`Teddy Wing
Not efficient to send a request to the TomTom API every time we save a Route, but I'm banking on developing a cache system soon to avoid having to make the requests, so hopefully that will stop this from making expensive remote calls all the time. Refs #6095
2018-03-23Route: Fix whitespaceTeddy Wing
This method wasn't indented to the same level as the rest of the file. Refs #6095
2018-03-23Route: Add `#calculate_costs!` to populate `#costs` with `WayCost`sTeddy Wing
This new method will launch a worker that takes the route's `StopArea`s, converts them to `WayCost`s, sends them to the TomTom API to calculate distance and time costs, and saves those costs to the route's `costs` field. Refs #6095
2018-03-23Route: Get rid of unnecessary whitespaceTeddy Wing
Refs #6095
2018-03-16Refs #6218; UI for exportsZog
2018-03-15Merge pull request #376 from af83/6006-fix-stops-filterAlban Peignier
Fix VehicleJourney#with_ordered_stop_area_ids scope. Refs #6006
2018-03-15Add StopArea#status in stop_areas#_form. Refs #60336033-stop-area-statesAlban Peignier
2018-03-15Refs #6033 Update activate and deactivate methodscedricnjanga
2018-03-14Merge pull request #367 from af83/6042-detailed_purchase_windowsAlban Peignier
Add detailed view for purchase windows. Refs #6042
2018-03-14Refs #6021: Make DAY_OFFSET_MAX configurableZog
2018-03-14Refs #6021 @1h; Allow journeys to span over 3 daysZog
And fix the way offsets are computed to use the timezones
2018-03-14Refs #5972 @1h; Automatic registration_number generationZog
2018-03-13Refs #6006; Fix VehicleJourney#with_ordered_stop_area_ids scope6006-fix-stops-filterZog
2018-03-09Refs #6042; Add detailed view for purchazse windows6042-detailed_purchase_windowsZog
2018-03-07Chouette::Line#by_name: Use `LEFT OUTER JOIN` on "companies"Teddy Wing
Thanks to Johan for helping me with this. He correctly remarked that what I had before will do an `INNER JOIN`, which ends up excluding lines that don't have an associated company. I didn't really think about the data, and didn't realise we had lines without a company. Big thanks to Johan for seeing that I needed to add `public.` to qualify the `companies` table in order for the join to work. Otherwise it doesn't work correctly and we can't filter by company name. Refs #5889
2018-03-07AutocompleteLines: Sanitize `:q` param in `LIKE` operatorTeddy Wing
Johan made a number of good points here: > * I think this belongs in the model > * I would rather use a named parameter here > `.where('lines.number LIKE :q OR lines.names LIKE :q ...', q: > "%#{params[:q]}%")` > * You should defiitely escape the params before passing it to your db. > `sanitize_sql_like` seems like the best choice here I wasn't thinking about sanitisation at all and just assumed the `?`s in the prepared statement would take care of it for me. But obviously, we're passing `%`s in the param, so users can of course do the same thing. Protect against this using the `ActiveRecord::Sanitization#sanitize_sql_like` method. This is a private class method, so in order to use it we have to call it from inside the `Chouette::Line` model. And of course the named parameters are a no-brainer. At the time, I had seen that `Array` splat somewhere else in the codebase and just blindly copied the format, forgetting that named parameters even existed. Refs #5889
2018-03-07VehicleJourney: Remove `.lines` methodTeddy Wing
This is no longer needed thanks to the `AutocompleteLinesController` and the AJAX filter in `app/views/referential_vehicle_journeys/_filters.html.slim`. Refs #5889
2018-03-07ReferentialVehicleJourneys#index: Make lines filter asynchronousTeddy Wing
Instead of doing a complex query to get the lines available to filter on, just get all the lines in the current referential. We then filter those by what was typed into the select2 box and asynchronously respond with line options in a new JSON autocomplete controller. Here we're only providing the option to filter by `number` and `name` field on the line. I'd like to filter by everything in the `#display_name`. I don't think the objectid is going to be easy to integrate into the SQL query but I'd like to add the company part. It's possible we could do the objectid filter in Ruby instead of the database query. Refs #5889
2018-03-05Merge pull request #359 from af83/6068-simple-exporterAlban Peignier
Simple exporter. Refs #6068
2018-03-05Remove primary_key overriding in models. Refs #6112Alban Peignier