Skip to content

Commit

Permalink
fix seed breaking from UsersFetcher changes
Browse files Browse the repository at this point in the history
  • Loading branch information
petermueller committed Apr 22, 2015
1 parent f62647e commit b6dfd93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/workers/libraries_fetcher.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class LibrariesFetcher
include Sidekiq::Worker

def perform(game_ids, library_id)
def perform(game_ids, library_id = nil)
game_ids.each_slice(100) do |slice|
GamesFetcher.perform_async(slice, library_id)
end
Expand Down
9 changes: 5 additions & 4 deletions app/workers/users_fetcher.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class UsersFetcher
include Sidekiq::Worker

def perform(bgg_username,library_id)
library = Library.find_by(id: library_id)
def perform(bgg_username,library_id = nil)
library = Library.find_by(id: library_id) if library_id
bgg_user_library = BggApi.new.collection({ username: bgg_username })
existing_games_array = library.games.map { |game| game.bgg_id }
existing_games_array = []
existing_games_array += library.games.map { |game| game.bgg_id } if library
collection_array = bgg_user_library["item"].map { |game| game["objectid"].to_i }
collection_array -= existing_games_array
LibrariesFetcher.perform_async(collection_array, library.id)
LibrariesFetcher.perform_async(collection_array, library_id)
end
end

0 comments on commit b6dfd93

Please sign in to comment.