comparison sql/job-todo.sql @ 6:8c408176d2b1

scid: past jobs are not listed for new workers
author David Demelier <markand@malikania.fr>
date Wed, 23 Jun 2021 11:44:30 +0200
parents 9c4fea43803c
children de4bf839b565
comparison
equal deleted inserted replaced
5:566bc028cdcb 6:8c408176d2b1
1 SELECT job.id 1 --
2 , job.tag 2 -- job-todo.sql -- list jobs to perform for a worker
3 , job.project_id 3 --
4 FROM job 4 -- Copyright (c) 2021 David Demelier <markand@malikania.fr>
5 WHERE job.id 5 --
6 NOT IN ( 6 -- Permission to use, copy, modify, and/or distribute this software for any
7 SELECT jobresult.job_id 7 -- purpose with or without fee is hereby granted, provided that the above
8 FROM jobresult 8 -- copyright notice and this permission notice appear in all copies.
9 WHERE jobresult.worker_id = ? 9 --
10 ) 10 -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 LIMIT ? 11 -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 --
18
19 --
20 -- This request won't list jobs that were created before the worker itself
21 -- otherwise when adding a new worker it would need to run potentially a very
22 -- high number of jobs
23 --
24 SELECT job.id
25 , job.tag
26 , job.project_id
27 FROM job
28 WHERE job.id
29 NOT IN (
30 SELECT jobresult.job_id
31 FROM jobresult
32 WHERE jobresult.worker_id = ?
33 )
34 AND job.date >= (
35 SELECT worker.date
36 FROM worker
37 WHERE worker.id = ?
38 )
39 LIMIT ?