Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Create projects by the buckets automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Ringling committed May 8, 2017
1 parent 1b62a2d commit 71fea2d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/jobs/pull_test_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class PullTestResultsJob < ActiveJob::Base
queue_as :default

def perform(*args)
Project.create_from_s3_dir

Project.all.each do |project|
p "pulling results for #{project.name}"
project.refresh_project_and_pull_results
Expand Down
6 changes: 6 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def s3Wrapper
@s3Wrapper ||= S3Wrapper.new
end

def self.create_from_s3_dir
S3Wrapper.new.project_names.each do |project_name|
Project.find_or_create_by!(name: project_name)
end
end

def refresh_project_and_pull_results
process_suites
process_builds_and_pull_results
Expand Down
4 changes: 4 additions & 0 deletions app/models/s3_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def file_modified_date(filename)
bucket.objects(prefix: filename).first.last_modified
end

def project_names
bucket.objects(delimiter: '/').batches.first.response.common_prefixes.map{|cp| cp.prefix[0..-2]}
end

def file_list_from_project(project_name)
@file_list_from_project ||= begin
list = []
Expand Down
Binary file added vendor/cache/metaclass-0.0.4.gem
Binary file not shown.
Binary file added vendor/cache/mocha-1.2.1.gem
Binary file not shown.

0 comments on commit 71fea2d

Please sign in to comment.