File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
lib/travis/api/v3/queries Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ def find(build)
13
13
end
14
14
15
15
def filter ( relation )
16
- relation = relation . where ( state : ACTIVE_STATES ) if bool ( active )
17
- relation = relation . where ( state : list ( state ) ) if state
18
16
relation = for_owner ( relation ) if created_by
19
17
20
18
relation = relation . includes ( :build )
@@ -36,8 +34,7 @@ def for_owner(relation)
36
34
37
35
def for_user ( user )
38
36
set_custom_timeout ( host_timeout )
39
- fragment = "SELECT repository_id FROM permissions where user_id = #{ user . id } "
40
- jobs = V3 ::Models ::Job . where ( "EXISTS (#{ fragment } ) AND jobs.repository_id IN (#{ fragment } )" )
37
+ jobs = V3 ::Models ::Job . where ( "jobs.id in (select id from most_recent_job_ids_for_user_repositories_by_states(#{ user . id } , ?))" , states )
41
38
42
39
sort filter ( jobs )
43
40
end
@@ -48,5 +45,15 @@ def stats_by_queue(queue)
48
45
. count
49
46
Models ::JobsStats . new ( stats , queue )
50
47
end
48
+
49
+ private
50
+
51
+ def states
52
+ s = [ ]
53
+ s << ACTIVE_STATES if bool ( active )
54
+ s << list ( state ) if state
55
+ return '' if s . empty?
56
+ s . flatten . uniq . join ( ',' )
57
+ end
51
58
end
52
59
end
You can’t perform that action at this time.
0 commit comments