Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Fix https://github.com/aylei/leetcode-rust/issues/3 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ extern crate reqwest;

use std::fmt::{Display, Formatter, Error};

const PROBLEMS_URL: &str = "https://leetcode.com/api/problems/algorithms/";
const GRAPHQL_URL: &str = "https://leetcode.com/graphql";
const PROBLEMS_URL: &str = "https://leetcode-cn.com/api/problems/algorithms/";
const GRAPHQL_URL: &str = "https://leetcode-cn.com/graphql";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a command line argument to override the hostname?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll add it

const QUESTION_QUERY_STRING: &str = r#"
query questionData($titleSlug: String!) {
question(titleSlug: $titleSlug) {
Expand All @@ -20,7 +20,7 @@ const QUESTION_QUERY_OPERATION: &str = "questionData";
pub fn get_problem(id: u32) -> Option<Problem> {
let problems = get_problems().unwrap();
for problem in problems.stat_status_pairs.iter() {
if problem.stat.question_id == id {
if problem.stat.frontend_question_id == id {
aylei marked this conversation as resolved.
Show resolved Hide resolved
let client = reqwest::Client::new();
let resp: RawProblem = client.post(GRAPHQL_URL)
.json(&Query::question_query(problem.stat.question_title_slug.as_ref().unwrap()))
Expand Down