Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Commit 64962b1

Browse files
committed
merge get_question_detail and get_contest_question_detail
1 parent 1d32cfc commit 64962b1

File tree

2 files changed

+5
-44
lines changed

2 files changed

+5
-44
lines changed

‎src/cache/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ impl Cache {
117117
/// TODO: implement caching
118118
/// Get contest
119119
pub async fn get_contest(&self, contest: &str) -> Result<Contest, Error> {
120-
let ctest = self.0
120+
let ctest:Value = self.0
121121
.get_contest_info(contest)
122122
.await?
123123
.json()
124124
.await?;
125+
debug!("{:?}", ctest.to_string());
125126
let ctest = parser::contest(ctest).ok_or(Error::NoneError)?;
126127
Ok(ctest)
127128
}
@@ -211,11 +212,10 @@ impl Cache {
211212
Ok(rdesc)
212213
}
213214

214-
// TODO: we can probably use this for all questions in general, actually
215215
/// Get contest question
216216
pub async fn get_contest_qnp(&self, problem: &str) -> Result<(Problem,Question), Error> {
217217
let graphql_res = self.0
218-
.get_contest_question_detail(problem)
218+
.get_question_detail(problem)
219219
.await?
220220
.json()
221221
.await?;

‎src/plugins/leetcode.rs

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -160,45 +160,6 @@ impl LeetCode {
160160
).await
161161
}
162162

163-
//TODO: check if refer is necessary
164-
/// Get specific problem detail
165-
#[named]
166-
pub async fn get_question_detail(&self, slug: &str) -> Result<Response, Error> {
167-
trace!("Requesting {} detail...", &slug);
168-
let refer = self.conf.sys.urls.get("problems").ok_or(Error::NoneError)?.replace("$slug", slug);
169-
let url = &self.conf.sys.urls.get("graphql").ok_or(Error::NoneError)?;
170-
let mut json: Json = HashMap::new();
171-
json.insert(
172-
"query",
173-
"query a($titleSlug: String!) {
174-
question(titleSlug: $titleSlug) {
175-
content
176-
stats
177-
codeDefinition
178-
sampleTestCase
179-
exampleTestcases
180-
enableRunCode
181-
metaData
182-
translatedContent
183-
}
184-
}".to_owned()
185-
);
186-
187-
json.insert(
188-
"variables",
189-
r#"{"titleSlug": "$titleSlug"}"#.replace("$titleSlug", slug),
190-
);
191-
192-
json.insert("operationName", "a".to_string());
193-
194-
let mut req = make_req!(self, url.to_string());
195-
req.mode = Mode::Post(json);
196-
req.refer = Some(refer);
197-
req
198-
.send(&self.client)
199-
.await
200-
}
201-
202163
/// Register for a contest
203164
#[named]
204165
pub async fn register_contest(&self, contest: &str) -> Result<Response,Error> {
@@ -226,8 +187,8 @@ impl LeetCode {
226187
.await
227188
}
228189

229-
/// Get contest problem detail
230-
pub async fn get_contest_question_detail(&self, problem: &str) -> Result<Response,Error> {
190+
/// Get full question detail
191+
pub async fn get_question_detail(&self, problem: &str) -> Result<Response,Error> {
231192
self.get_graphql("query a($s: String!) {
232193
question(titleSlug: $s) {
233194
title

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /