Skip to content

Commit 15028cb

Browse files
committed
Fix executions CSV export attempt
1 parent 2d5f2e8 commit 15028cb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/travis/api/v3/renderer/execution.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Travis::API::V3
22
class Renderer::Execution < ModelRenderer
33
representation :minimal, :id, :os, :instance_size, :arch, :virtualization_type, :queue, :job_id,
44
:repository_id, :owner_id, :owner_type, :plan_id, :sender_id, :credits_consumed, :started_at,
5-
:finished_at, :created_at, :updated_at
5+
:finished_at, :created_at, :updated_at, :sender_login, :repo_slug, :repo_owner_name
66
representation :standard, *representations[:minimal]
77
end
88
end

lib/travis/api/v3/services/executions/for_owner.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,23 @@ def run!
1212
raise NotFound unless owner
1313
raise InsufficientAccess unless access_control.visible?(owner)
1414

15-
result query(:executions).for_owner(owner, access_control.user.id, params['page'] || 0,
15+
results = query(:executions).for_owner(owner, access_control.user.id, params['page'] || 0,
1616
params['per_page'] || 0, params['from'], params['to'])
17+
result presented_results(results)
18+
end
19+
20+
def presented_results(results)
21+
senders = Travis::API::V3::Models::User.where(id: results.map(&:sender_id)).index_by(&:id)
22+
repositories = Travis::API::V3::Models::Repository.where(id: results.map(&:repository_id)).index_by(&:id)
23+
24+
results.map do |execution|
25+
execution[:sender_login] = senders[execution[:sender_id]]&.login || 'Unknown Sender'
26+
repo = repositories[execution[:repository_id]]
27+
execution[:repo_slug] = repo&.slug || 'Unknown Repository'
28+
execution[:repo_owner_name] = repo&.owner_name || 'Unknown Repository Owner'
29+
30+
execution
31+
end
1732
end
1833
end
1934
end

0 commit comments

Comments
 (0)