Commit graph

88 commits

Author SHA1 Message Date
Pierre de La Morinerie
fbfe5c3817 jobs: also retry native ActiveStorage's jobs on transient errors 2021-04-29 14:08:12 +02:00
Pierre de La Morinerie
684af77e35 jobs: extract an RetryOnTranscientErrors concern 2021-04-29 14:08:12 +02:00
simon lehericey
d552e364fc retry 5 times on integrity error and then block processing 2021-04-06 18:03:39 +02:00
Pierre de La Morinerie
75a1046315 active_storage: refactor concerns
Follow-up of #5953.

Refactor the concerns with two goals:

- Getting closer from the way ActiveStorage adds its own hooks.
  Usually ActiveStorage does this using an `Attachment#after_create`
  hook, which then delegates to the blob to enqueue the job.
- Enqueuing each job only once. By hooking on `Attachment#after_create`,
  we guarantee each job will be added only once.

We then let the jobs themselves check if they are relevant or not, and
retry or discard themselves if necessary.

We also need to update the tests a bit, because Rails'
`perform_enqueued_jobs(&block)` test helper doesn't honor the `retry_on`
clause of jobs. Instead it forwards the exception to the caller – which
makes the test fail.

Instead we use the inline version of `perform_enqueued_jobs()`, without
a block, which properly ignores errors catched by retry_on.
2021-03-16 11:49:14 +01:00
Paul Chavard
96a832bc19 Add SerializerService 2021-03-02 12:42:22 +01:00
Pierre de La Morinerie
150ddab660 zeitwerk: Api -> API 2021-02-09 13:07:30 +01:00
Paul Chavard
a591d5528e Add job exception log methods to champ and dossier 2021-02-05 18:56:27 +01:00
Paul Chavard
41c3a98d7d Update Raven references to use Sentry 2021-01-28 19:46:36 +01:00
simon lehericey
650a598698 ensure a buggy procedure does not block the others from being closed 2021-01-19 10:42:16 +01:00
simon lehericey
5bc4fab0c4 exhaustive test of discarded_dossier_deletion_job 2020-12-16 15:00:26 +01:00
kara Diaby
c7643154d1 final optims after sim review 2020-12-16 15:00:26 +01:00
kara Diaby
f3c4040d2d add grace period to deleted dossiers 2020-12-16 15:00:26 +01:00
kara Diaby
f748ccfc9e Appelle l'API entreprise avec le token en Header 2020-12-10 17:49:49 +01:00
clemkeirua
513d4f6ff1 move all the cron jobs in a dedicated directory 2020-12-08 13:22:43 +00:00
simon lehericey
b187244a29 extract and refactor api errors 2020-12-04 17:07:30 +01:00
simon lehericey
05e9130634 refator test 2020-12-03 11:52:01 +01:00
simon lehericey
f56235c7ee retry exponentially on api entreprise timeout 2020-12-03 11:52:01 +01:00
simon lehericey
9eab310565 [#5675] for all api entreprise job, retry on 502, 503 2020-12-02 18:25:31 +01:00
simon lehericey
c563956a9f retry each day during 5 days to fetch attestation social 2020-10-28 15:53:58 +00:00
clemkeirua
245e9e59c7 do not run ApiEntreprise jobs on missing etablissements 2020-09-28 17:36:38 +02:00
simon lehericey
86b04d4275 Add a missing test on job retry to the excon err 2020-09-09 09:08:48 +00:00
Paul Chavard
d1e0b65658 update jobs specs to use revisions 2020-09-02 11:26:26 +02:00
Pierre de La Morinerie
6328011f60 models: require belong_to associations on champ
- Make `champ.dossier` a requirement;
- Move the dossier_id assignation to `before_validation` (otherwise
the record is invalid, and never gets saved);
- Allow specs to only build the champ (instead of saving it to the
database), which bypasses the requirement to have a dossier.
2020-08-18 15:57:37 +02:00
Paul Chavard
bb5a90da76 fix active_revision_id -> active_revision.id 2020-07-23 15:07:25 +02:00
Pierre de La Morinerie
7a67f1a802 jobs: ignore missing blob during virus scan
We currently have many failed VirusScannerJob enqueued, because the
underlying blob is missing.

This PR fixes the issue by discarding the job in those cases (because if
the blob is gone, the job is never going to succeed).

The implementation is based on a similar issue encoutered by the
ActiveStorage::AnalyzeJob. See 06f8baf73c
2020-07-13 14:35:41 +02:00
Pierre de La Morinerie
b82c269cef specs: test de-serialization of job arguments
When the job is invoked directly, the serialization and de-serialization
of the job arguments is not actually tested.

Using `perform_later` inside a `perform_enqueued_jobs` allows to
exercise the serialization.
2020-07-13 14:31:28 +02:00
Christophe Robillard
954d41ce4e fetch effectifs mensuels for may month 2020-06-24 10:23:00 +02:00
Christophe Robillard
8df9ae3a8d ask only effectifs for april 2020-06-10 17:41:13 +02:00
Christophe Robillard
f4ebb5d107 create api_entreprise jobs 2020-05-20 11:09:54 +02:00
Pierre de La Morinerie
4cb747fdb6 specs: always require rails_helper
Test helpers are separated between two files: spec_helper and
rails_helper. This separation is meant to allow tests that do not
require Rails (like testing standalone libs) to boot faster.

The spec_helper file is always loaded, through `--require spec_helper`
in the `.rspec` config file. When needed, the rails_helper file is
expected to be required manually.

This is fine, but:
- Many test files have a redundant `require 'spec_helper'` line;
- Many test files should require `rails_helper`, but don't.

Not requiring `rails_helper` will cause the Rails-concerned section of
the test environment not to be configured–which may cause subtle bugs
(like the test database not being properly initialized).

Moreover, Spring loads all the Rails files on preloading anyway. So the
gains from using only `spec_helper` are thin.

To streamline this process, this commit:
- Configures `.rspec` to require `rails_helper` by default;
- Remove all manual requires to spec_helper or rails_helper.

Reference: https://stackoverflow.com/questions/24145329/how-is-spec-rails-helper-rb-different-from-spec-spec-helper-rb-do-i-need-it
2020-03-31 12:48:32 +02:00
Paul Chavard
742cc15209 Use base CronJob 2020-03-31 12:25:46 +02:00
Paul Chavard
33bf2fe109 remove deprecated AutoReceiveDossiersForProcedureJob 2020-03-31 12:25:46 +02:00
Paul Chavard
5b5ae5a7a5 Do not send notifications or create operation logs on brouillon demarches 2020-03-25 15:04:52 +01:00
Paul Chavard
1ce1c1e6d0 use discard 2020-02-13 12:31:59 +01:00
maatinito
9672d892e9 Bug with time zone: Time.zone.today looses time_zone and may breaks database comparisons 2019-12-11 17:34:10 +01:00
Paul Chavard
7b947feae4 Rename demarche archivée to demarche close 2019-11-28 15:07:16 +01:00
maatinito
14bc2b99b9 auto-archive badly occurs in UTC time and not in local time (1 hour too late in France, 10 hours before in Tahiti ;-) 2019-11-25 14:39:42 +01:00
simon lehericey
8ae592fe25 [fix #4361] administrateur active 2019-10-24 18:32:48 +02:00
simon lehericey
e3e6bc7689 ! NEED JOB REBOOT Move remind activation logic to user 2019-08-14 16:34:50 +02:00
simon lehericey
3fde2a6f70 Rename gestionnaire in code to instructeur 2019-08-12 13:47:01 +02:00
Paul Chavard
6cfad01d12 Stop using Flipflop as switch for weekly_overview 2019-07-31 15:15:09 +02:00
Paul Chavard
46c1bbbc6f Official support for declarative demarches 2019-07-02 14:12:26 +02:00
Paul Chavard
dba8d65137 Track dossier operations with author and subject 2019-05-14 14:31:03 +02:00
Paul Chavard
f113d108c9 Save virus scan status to blob metadata 2019-05-02 15:58:09 +02:00
simon lehericey
99bfd19b41 [fix #3268] Jobs: use automatic_operation 2019-01-16 17:20:12 +01:00
Paul Chavard
98d388b64d Use state change methods on dossier in dossier auto archive job 2018-11-27 12:49:40 +01:00
Paul Chavard
b5b6832be8 Use state change methods on dossier in dossier auto recieve job 2018-11-27 12:49:40 +01:00
simon lehericey
e684cec516 DateTime.new => Time.zone.local 2018-10-26 10:10:20 +00:00
Frederic Merizen
7631bde16a [#2550] Generate attestation on auto-accepted dossier 2018-09-25 15:53:57 +02:00
Frederic Merizen
5e16b5d80e [#1946] Set en_instruction_at for factorybot-created dossiers 2018-09-20 17:44:31 +02:00