Skip to content

Commit

Permalink
Move anilist query parse to runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Apr 22, 2024
1 parent 84b2a3d commit 3ca6d75
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/list_import/anilist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def count

def each
%w[anime manga].each do |type|
send("#{type}_list").each do |media|
send(:"#{type}_list").each do |media|
row = Row.new(media, type)

yield row.media, row.data
Expand All @@ -48,14 +48,15 @@ def user_exists?

def media_lists
@media_lists ||= AnilistApiWrapper::Client.query(
MEDIA_LIST_QUERY,
self.class.media_list_query,
variables: {
user_name: input_text
}
)
end

MEDIA_LIST_QUERY = AnilistApiWrapper::Client.parse <<-GRAPHQL
def self.media_list_query
@media_list_query ||= AnilistApiWrapper::Client.parse <<-GRAPHQL
query($user_name: String) {
anime: MediaListCollection(userName: $user_name, type: ANIME) {
lists {
Expand Down Expand Up @@ -128,7 +129,8 @@ def media_lists
}
}
}
GRAPHQL
GRAPHQL
end

rescue StandardError => e
Sentry.capture_exception(e)
Expand Down

0 comments on commit 3ca6d75

Please sign in to comment.