Skip to content

Commit 8346640

Browse files
committed
first try to get games
1 parent 97bdcb7 commit 8346640

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/providers/smash_gg/get_tournaments_by_country.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
class SmashGg::GetTournamentsByCountry
2+
# Melee ID: 1
3+
# Tekken ID: 17
4+
# Ultimate ID : 1386
5+
# MarioKart8 Deluxe : 2165
6+
#
7+
28
TournamentsQuery = GraphClient.parse <<-'GRAPHQL'
39
query($cCode: String!, $perPage: Int!) {
410
tournaments(query: { perPage: $perPage,
@@ -16,6 +22,12 @@ class SmashGg::GetTournamentsByCountry
1622
mapsPlaceId
1723
venueAddress
1824
venueName
25+
events {
26+
videogame {
27+
id
28+
name
29+
}
30+
}
1931
}
2032
}
2133
}
@@ -26,6 +38,10 @@ def self.call(country: "FR", page_size: 25)
2638
format(results.dup)
2739
end
2840

41+
def self.videogames(hash)
42+
hash['events'].map{|e| e.dig('name')}.uniq
43+
end
44+
2945
def self.format(results)
3046
results.map do |hash|
3147
new_hash = hash.dup
@@ -36,6 +52,7 @@ def self.format(results)
3652
new_hash[:venue_name] = new_hash.delete('venueName')
3753
new_hash[:address] = new_hash.delete('venueAddress')
3854
new_hash[:google_place_id] = new_hash.delete('mapsPlaceId')
55+
new_hash[:games] = videogames(hash)
3956
new_hash.with_indifferent_access
4057
end
4158
end

0 commit comments

Comments
 (0)