Commit Graph

23 Commits

Author SHA1 Message Date
Chris Hill-Scott
45579c59cd Store boolean values in Redis as valid JSON
Calling `.set()` with `True` stores the byte string `'True'` which
cannot subsequently be decoded from JSON (because boolean values in
JSON are lowercase, ie `true`).
2018-07-31 12:17:28 +01:00
Chris Hill-Scott
0906eb019d Check that API is not called when result is cached
Good to explicitly test this (rather than relying on an exception not
being raised).
2018-07-31 10:05:10 +01:00
Chris Hill-Scott
505de52d38 Check if any jobs exist before querying jobs
At the moment the dashboard does two API calls to find out if a service
has:

1. Scheduled jobs
2. Normal jobs

API calls are slow because they are synchronous, go over the network and
touch the database. We can’t cache these API calls because:
- a scheduled job could become a normal job at any time
- the statistics on a normal job are constantly updating

However there are plenty of services which don’t have any jobs, and
probably never will. And finding out if a service has any jobs is
reliably cacheable (because as soon as a service creates its first job
it has some jobs).

So this commit:
- refactors the way we get scheduled/normal jobs into the job_api_client
  to make the view a bit slimmer
- makes an additional, Redis-wrapped call to find out if any jobs exist
  before trying to get the jobs

This should result in a speedup on the dashboard, and can be used in the
future if there’s anywhere else we want to show or hide something
depending on whether a service has created any jobs (I have some ideas).
2018-07-30 11:14:01 +01:00
Chris Hill-Scott
98214884d3 Stop posting job metadata to the API
The API is looking at the S3 metadata for this information now, so
there’s no need for us to continue sending it through.
2018-05-01 09:47:04 +01:00
Venus Bailey
cbe2df3946 Revert "Job stats table" 2017-08-16 15:25:26 +01:00
venusbb
6a483c14f5 change get-jobs to point to new statistics tables 2017-08-15 15:53:26 +01:00
Leo Hemsted
0fdd38b9c5 add tests for new jobs functionality 2016-10-10 17:15:57 +01:00
Leo Hemsted
aa458a15da update tests to reflect new code
also change jobs.py to filter out test jobs (since we dont need to see em)
and to use the new statuses filter rather than filtering on front end
2016-10-10 15:43:01 +01:00
Leo Hemsted
549a17c1f7 separate get_job and get_jobs in job_api_client
also remove the status parameter, as we never use it anywhere
2016-10-10 15:43:01 +01:00
Chris Hill-Scott
93ca29eab8 Merge pull request #922 from alphagov/cancelled-jobs
Let users cancel a job
2016-09-06 17:12:19 +01:00
Chris Hill-Scott
eb11615a32 Add a cancel job button
If you schedule a job you might change your mind or circumstances might
change. So you need to be able to cancel it. This commit adds a button
on the job page which hits the `…/cancel` API endpoint for a job.
2016-09-06 16:55:24 +01:00
Martyn Inglis
2f56643e3a Fix up issues caused by merge
- statistics now on job_json
- removed test that validates we handle the case where job has no statistics key - never happens
2016-09-05 14:45:34 +01:00
Martyn Inglis
1ad2665bfe Merge branch 'master' into remove-code-that-handled-old-new-job-api
Conflicts:
	app/main/views/jobs.py
	app/notify_client/job_api_client.py
2016-09-05 14:29:58 +01:00
Chris Hill-Scott
be90cf2783 Make sure create job client can handle statistics
The create job endpoint returns the data about the job with a `data:`
wrapper. This commit makes sure that, when the client is trying to
process a job which has just been created, it looks inside the `data`
wrapper.
2016-09-01 13:43:15 +01:00
Chris Hill-Scott
225a61ddd3 Add a component for picking the time to send a job
Users need to pick a time in the next 24hrs, or send a file immediately.

Rationale for this is a bit lost in time-before-holiday, but generally:

‘Now’ and ‘later’ as the inital choices makes it really clear what
this feature is about conceptually.

The choice of times is absolute, eg ‘1pm’ not ‘in 3 hours’
2016-08-31 16:58:09 +01:00
Chris Hill-Scott
7324b30dbc Re-add a 'requested' stat to a job
It’s useful to know how many notifications we’ve handed off to our
providers. This is a measure of how complete the processing of the job
is.

This is important, because once the job processing is complete then you
can accurately reconcile the report with the CSV file that you’ve
uploaded.
2016-08-30 14:57:28 +01:00
Martyn Inglis
fc3af8b56e Extra test for the zero stats case 2016-08-26 15:27:04 +01:00
Martyn Inglis
8c159da3ea Fix for admin app to show job data on dashboard page
- uses the new stats block in the API to build the stats expected by the dashboard page
- all work done in client
2016-08-26 15:21:10 +01:00
Martyn Inglis
fb9b33e3de Removed check on notifications-sent, that was used to check whether it was old or new style API.
Now new style is deployed it's not needed.

Tests updated to reflect this,
2016-08-25 12:54:23 +01:00
Martyn Inglis
9b348880ef Test for old style stats - make sure we don't override / fail if no new block present. 2016-08-24 10:42:57 +01:00
Martyn Inglis
5b2ae43d5d Wrote some tests around the stats conversions.
Properly named the finished parameter.

Handled the root JSON key
2016-08-24 10:35:04 +01:00
Chris Hill-Scott
da1fa2e61c Make _attach_current_user a pure function
Mutating dictionaries is gross and doesn’t work as you’d expect. Better
to have the function return a new dictionary instead.

Means we can be explicit that `created_by` is one of the allowed params
when updating a service.
2016-08-11 17:07:55 +01:00
Leo Hemsted
5bd90bba64 make test folder structure align with app folder structure 2016-07-15 15:23:40 +01:00