aboutsummaryrefslogtreecommitdiffstats
path: root/app/workers
AgeCommit message (Collapse)Author
2018-03-26Refs #6218; Link exports to referentialsZog
2018-03-14RouteWayCostWorker: Add comment about recursive workersTeddy Wing
Explain why we need to skip and un-skip the callback. Refs #6095
2018-03-14RouteWayCostWorker: Fix recursive worker callTeddy Wing
Since this method was run on `after_save` and in it `RouteWayCostCalculator` calls `#update` on the given route, it caused an infinite recursive call to the worker. To prevent this, wrap the `#calculate!` call in methods that unset and reset the callback. Refs #6095
2018-03-14RouteWayCostWorker: 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-14Route: 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-12Refs #6133; Full UX for exportsZog
Also added a *dumb* `WorkgroupExport` for testing purposes.
2018-03-12Refs #6133: Async exportsZog
2018-03-12Refs #6133; Fix specsZog
2018-02-22WorkbenchImportWorker: Use `File.unlink` instead of `#unlink`Teddy Wing
I was getting this error when I removed the `rescue nil`s: Failures: 1) WorkbenchImportWorker foreign lines uploads the following entries: ["OFFRE_TRANSDEV_20170301122517", "OFFRE_TRANSDEV_20170301122519"] Failure/Error: eg_file.unlink NoMethodError: undefined method `unlink' for #<File:0x007fef1adbace8> # ./app/workers/workbench_import_worker.rb:81:in `upload_entry_group_stream' # ./app/workers/workbench_import_worker.rb:52:in `upload_entry_group' # ./app/services/zip_service.rb:61:in `<<' # ./app/services/zip_service.rb:61:in `finish_current_output' # ./app/services/zip_service.rb:35:in `add_entry' # ./app/services/zip_service.rb:27:in `block in _subdirs' # .../.gem/ruby/2.3.3/gems/rubyzip-1.2.1/lib/zip/entry_set.rb:38:in `block in each' # .../.gem/ruby/2.3.3/gems/rubyzip-1.2.1/lib/zip/entry_set.rb:37:in `each' # .../.gem/ruby/2.3.3/gems/rubyzip-1.2.1/lib/zip/entry_set.rb:37:in `each' # .../.gem/ruby/2.3.3/gems/rubyzip-1.2.1/lib/zip/central_directory.rb:182:in `each' # ./app/services/zip_service.rb:26:in `_subdirs' # .../.gem/ruby/2.3.3/gems/rubyzip-1.2.1/lib/zip/file.rb:133:in `open_buffer' # ./app/services/zip_service.rb:21:in `block in subdirs' # ./app/workers/workbench_import_worker.rb:39:in `each' # ./app/workers/workbench_import_worker.rb:39:in `each_with_index' # ./app/workers/workbench_import_worker.rb:39:in `upload' # ./app/workers/workbench_import_worker.rb:19:in `perform' # ./spec/workers/workbench_import_worker_spec.rb:68:in `block (4 levels) in <top (required)>' # ./spec/workers/workbench_import_worker_spec.rb:68:in `block (3 levels) in <top (required)>' # ./spec/workers/workbench_import_worker_spec.rb:13:in `instance_eval' # ./spec/workers/workbench_import_worker_spec.rb:13:in `block in expect_upload_with' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency' # .../.gem/ruby/2.3.3/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load' # .../.gem/ruby/2.3.3/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call' # -e:1:in `<main>' Johan said that in his tests on his local machine, the temp files weren't getting deleted. When I try running the specs, the temp files do get deleted, so not sure what was going on. Figure it may be because of the `rescue nil`s, so I decided to remove those in the hopes of always ensuring we close and unlink the temp files. The trouble with doing that, however, was that it caused the error and thus test failures like the example above. I managed to fix the problem by using `File.unlink` instead of the instance method. Hopefully this works to ensure that the temp files are always deleted. Refs #4315
2018-02-22WorkbenchImportWorker: Reinstate creation of `./tmp/imports`Teddy Wing
If the directory doesn't exist, we should create it to ensure we don't get errors trying to write to a location that doesn't exist. I had removed this because I assumed the dir would be created during deployment, but I guess I shouldn't assume. Also, we want to ensure the dir gets created on dev machines without errors. This line is updated from last time where we'd create `Rails.root.join('tmp', 'imports')`. Now we use our `#temp_directory`, which can be variable. Refs #4315
2018-02-22WorkbenchImportWorker: Use temp files for entry group subdir ZipsTeddy Wing
Instead of creating our own files for these subdirectory Zip files, use temp files. There are two advantages to doing this: 1. We can customise the location they get saved to. This means we can use `Rails.root` as a default, but specify a custom location in a Rails config variable. 2. The files will be automatically deleted on every garbage collection. In actuality, #2 above was already handled by the `eg_file.unlink` line, and #1 could be easily added to the existing code. Using a `Tempfile`, though, makes the fact that these are temporary files more explicit. The reason why we want to be able to customise the location of these tempfiles is that in our production environment set up by Puppet, the `#{Rails.root}/tmp/imports` directory isn't writable by the application, which causes this code to error. We thus want a way to change the path in different environments. We keep the `eg_file.unlink` call here because we want the temporary file to be deleted as soon as possible. The Ruby documentation even recommends it (https://ruby-doc.org/stdlib-2.5.0/libdoc/tempfile/rdoc/Tempfile.html#class-Tempfile-label-Explicit+close): > it's good practice to do so: not explicitly deleting unused Tempfiles > can potentially leave behind large amounts of tempfiles on > the filesystem until they're garbage collected. I got rid of the `#upload_entry_group_tmpfile` method in this change, moving its contents to `#upload_entry_group_stream`. This was easy enough to do since it was only called in that one place. The reason I did this is because it took an open `File` object as an argument and closed the file at the end of the method. That's a major side effect. I don't think the method should be closing a file it doesn't own. After moving this work to `#upload_entry_group_stream`, we can close and unlink the file in the same place where it was created. Refs #4315
2018-01-09LineReferentialSyncWorker,StopAreaReferentialSyncWorker: Enable retryTeddy Wing
Now that Sidekiq retries are deactivated (3487ce6f34ef187a2a8daf170440f51f659c46b7), we need to enable retry on the workers that need it. We do want retry on the sync workers, so enable these locally in the worker classes. Refs #5495
2018-01-09Remove `retry: false` from workers since it's the new defaultTeddy Wing
As of 3487ce6f34ef187a2a8daf170440f51f659c46b7, we now default to `retry: false` on all our Sidekiq workers. Setting it in individual workers is now repetitious. Refs #5495
2018-01-05Create ReferentialCloning#clone_with_status! and #clone! for inline clone ↵Alban Peignier
usage. Refs #5283
2018-01-05Create first merge interface. Refs #5299Alban Peignier
2017-12-20Merge pull request #151 from ↵Luc Donnet
af83/5281-workbench-import-structural-bug-reading-zip 5281 workbench import structural bug reading zip
2017-12-20Merge pull request #124 from af83/5006-wb_import_filter_refs_with_foreign_linesLuc Donnet
5006 wb import filter refs with foreign lines
2017-12-15Fixes: #5281@1.2h; View specs and minor CR change from #50065281-workbench-import-structural-bug-reading-zipRobert
- CR change from #5006, severity of zip file messages :warning -> :error - View specs for showing import_messages
2017-12-14Refs: #5006@0.1h; Hotfix removed forgotten file.closeRobert
2017-12-14Hotfix removed forgotten file.close5006-wb_import_filter_refs_with_foreign_linesRobert
2017-12-14Refs #5006; CR pass IRobert
2017-12-14Fixes: #5006@10h;Robert
Implementation of Filtering Out Referentials with foreign lines in `app/workers/workbench_import_worker.rb` - Using ZipService with the set of allowed lines of the organisation - Fixing Integration Specs of the worker - Refactoring, Debugging and Rebasing
2017-12-13Use ReferentialCloning.find result without test on ↵Alban Peignier
ReferentialCloningWorker#perform. Refs #5283
2017-12-12Move logic to ReferentialCloning. Improve specs. Refs #5283Alban Peignier
2017-11-03Merge pull request #106 from ↵Robert Dober
af83/4782-create-worker-for-compliance-check-copy--rb201710301748 4782 create worker for compliance check copy rb201710301748
2017-10-31Refs: #4817@0.3h; Hotfix for wrong message for spurious directories in zip file4817-better-traductionRobert
2017-10-31Refs: #4817@0.1h; CodeReview related fix filename instead of import nameRobert
2017-10-31Fixes: #4817@0.35; Translations changed, Specs adpated to new translation ↵Robert
param name
2017-10-30ComplianceControlSetCopyWorker: Pass ComplianceCheckSet ID to JavaTeddy Wing
Previously I had been passing the `ComplianceControlSet` ID to the Java API. The API actually expects the ID of the `ComplianceCheckSet`. In order to get this ID, have the `ComplianceControlSetCopier` return the `ComplianceCheckSet` that it creates, and use that to pass the the ID to the Java API. Refs #4782
2017-10-30ComplianceControlSetCopyWorker: Call Java validation APITeddy Wing
Call the Java API URL to launch a validation after having copied the `ComplianceControlSet` into a `ComplianceCheckSet`. Copied the format with error logging from `NetexImport#launch_java_import`. In the test, make the ID variables global by putting them in `let`s. Add `config.iev_url` to the Rails `test` environment so that we can access this from our tests. TODO: I just realised I'm sending the wrong ID. I should be sending the check set ID. Refs #4782
2017-10-30Add ComplianceControlSetCopyWorkerTeddy Wing
A new worker that launches the work to copy a `ComplianceControlSet` to a `ComplianceCheckSet`. Currently only handles a single control set and referential pair. Probably want to extend this to handle multiple lists of these objects. Also need to add in a call to the Java API to validate the check. Refs #4782
2017-10-24Fixes: #4633;@0.5h; CR changesRobert
2017-10-24Fixes: #4633@0.5h; Implenting correct message for inconsistent zip fileRobert
2017-10-24Refs: #4633@1h; Implenting correct message for corrupt zip fileRobert
2017-10-24Refs: #4633@0.5h; WorkbenchImportWorker implements message creation for ↵Robert
spurious directories - Speced and implemented Missing: - Exact message parameters (change key from xxx, how to add names of spurious directories)
2017-10-24Refs: #4633@3h:Robert
- Discussing Spec - Speced and implemented the corrupt zipfile part Next: - Spec incorrect directory structure part - Implement incorrect directory structure part
2017-10-17Fixes: #4727@0.1h; Added organisation to clone for and rebased master4727-clone-compliance-control-setRobert
2017-10-17Fixes: #4727@0.5h; Worker speced and implementedRobert
2017-09-06Fix import messages when referential can't be created. Delete unused sass ↵Luc Donnet
files. Refs #4259
2017-08-31WorkbenchImportWorker: Use `#update` instead of `#update_attributes`Teddy Wing
The new form is `#update` and the specs (broken as they are) mock `#update`, so this call should do the same.
2017-08-29Set started_at & ended_at for WorkbenchImportWorker#performXinhui
Refs #4293
2017-08-28Don't use directly Rails.root/tmp directory (no writable on servers). Refs #4315Alban Peignier
2017-08-27Add .zip to uploaded filename (mandatory for java import ?). Refs #4273Alban Peignier
2017-08-27Make NetexImport#parent mandatory. Refs #4273Alban Peignier
2017-08-27Disable authentication in NetexImportsController for the moment. Refs #4273Alban Peignier
2017-08-25WorkbenchImportWorker#params: Remove unpermitted `referential_id`Teddy Wing
This param isn't permitted by the controller and we're currently not using it for anything. It produces a warning message in the logs, so I figured we should remove it. We may want to change the architecture to create referentials outside of the API, and thus would have to add this param in, but until then it's not needed.
2017-08-23Transferring code to Teddy; allowing him to do git push --force-with-leaseRobert
2017-08-22Refs: 4273@5h; Still debugging zip file upload inside post to Rails api; ↵Robert
Retry removed (but not the deadcode yet) [amend me]
2017-08-22Refs: #4273@3h;Robert
Debugging Java Integration (ZipService -> HTTPService -> Object Creation) - Created an ErrorFormat concern to see what went wrong in the HTTP call as so many things can go wrong due to: * Timeout Issues * Illegal database setup or cleaning before tests
2017-08-21Refs: #4273@20h; Reverse Engeneeiring RubyZip fixed ZipServiceRobert
- Replzed Lazy Enum over get_next_entry and group by with explicit looping and yielding to an instance level enumerator that yields streams per subdir (wich represents a referential). - Fixtures and Specs that use a REAL usecase. Next: Get rid of metadata kludge (should fix failing specs)