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

Commit

Permalink
Support the new GraphQL API for LeetCode
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Jan 27, 2022
1 parent 87eeb78 commit 002ac14
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/services/leet_code_service.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class LeetCodeService < SiteService
CONTESTS_URL = 'https://leetcode.com/contest/api/list'
CONTESTS_URL = 'https://leetcode.com/graphql?query={%20allContests%20{%20title%20titleSlug%20startTime%20duration%20__typename%20}%20}'
REQUEST_TYPE = RequestType::HTTP
DATA_OBJECT_TYPE = DataObjectType::JSON

private

def extract_contests data
data['contests']
data['data']['allContests']
end

def create_contests contests
Expand All @@ -24,7 +24,7 @@ def extract_contest_info contest
contest_info[:url] = "https://leetcode.com/contest/#{contest['title_slug']}"
contest_info[:duration] = contest['duration'].to_i

start_time = DateTime.strptime contest['start_time'].to_s, '%s'
start_time = DateTime.strptime contest['startTime'].to_s, '%s'
start_time = Time.parse start_time.to_s
end_time = start_time + contest_info[:duration]

Expand Down

0 comments on commit 002ac14

Please sign in to comment.