Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Resolve #40 - Spark job running too many times.
Browse files Browse the repository at this point in the history
- Use Collection, not WasapiFile in spark job
- update collection seeding job
- update db to have account in collection table
- this should probably be a join. whatever.
  • Loading branch information
ruebot committed Mar 1, 2018
1 parent 2ad4035 commit f5773b1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/collections_spark_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def after_perform

def perform(user_id, collection_id)
spark_shell = ENV['SPARK_SHELL']
WasapiFile.where('user_id = ? AND collection_id = ?', user_id, collection_id).each do |c|
Collection.where('user_id = ? AND collection_id = ?', user_id, collection_id).each do |c|
collection_path = ENV['DOWNLOAD_PATH'] +
'/' + c.account.to_s +
'/' + c.collection_id.to_s + '/'
Expand Down
3 changes: 2 additions & 1 deletion app/jobs/wasapi_files_populate_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def perform(user)
break if paginate.blank?
end
end
WasapiFile.distinct.select('user_id, collection_id').each do |cid|
WasapiFile.distinct.select('user_id, collection_id', 'account').each do |cid|
collection_api_request_url = AI_COLLECTION_API_URL + cid.collection_id.to_s
collection_api_request_code = HTTP.get(collection_api_request_url).code
if collection_api_request_code == 200
Expand All @@ -73,6 +73,7 @@ def perform(user)
Collection.find_or_create_by!(
collection_id: cid.collection_id,
user_id: cid.user_id,
account: cid.account,
title: collection_api_results['name'],
public: collection_api_results['publicly_visible']
)
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20180110143134_create_collections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ def change
create_table :collections, id: false, force: true do |t|
t.integer :collection_id, null: false
t.integer :user_id
t.integer :account
t.string :title
t.boolean :public

Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
create_table "collections", id: false, force: :cascade do |t|
t.integer "collection_id", null: false
t.integer "user_id"
t.integer "account"
t.string "title"
t.boolean "public"
t.datetime "created_at", null: false
Expand Down

0 comments on commit f5773b1

Please sign in to comment.