Skip to content

Commit 6719eee

Browse files
authored
Merge pull request #603 from shuzijun/gradle
fix #601
2 parents 5df7026 + fa494df commit 6719eee

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107

108108
[badge:plugin-homepage]: https://img.shields.io/badge/Plugin%20Home-Leetcode%20Editor-blue?logo=jetbrains&style=flat-square
109109
[badge:plugin-homepage-pro]: https://img.shields.io/badge/Pro%20Plugin%20Home-Leetcode%20Editor%20Pro-blue?logo=jetbrains&style=flat-square&color=blueviolet
110-
[badge:release]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Release?style=flat-square&logo=github&&label=Release%20Build
111-
[badge:snapshot]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Snapshot?style=flat-square&logo=github&&label=Snapshot%20Build
110+
[badge:release]: https://img.shields.io/github/actions/workflow/status/shuzijun/leetcode-editor/release.yml?branch=master&style=flat-square&logo=github&&label=Release%20Build
111+
[badge:snapshot]: https://img.shields.io/github/actions/workflow/status/shuzijun/leetcode-editor/snapshot.yml?branch=master&style=flat-square&logo=github&&label=Snapshot%20Build
112112
[badge:license]: https://img.shields.io/github/license/shuzijun/leetcode-editor.svg?style=flat-square&&label=License
113113
[badge:downloads]: https://img.shields.io/jetbrains/plugin/d/12132?style=flat-square&label=Plugin%20Downloads&logo=jetbrains
114114
[badge:version]: https://img.shields.io/jetbrains/plugin/v/12132?label=Plugin%20Version&logo=jetbrains&style=flat-square

README_ZH.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113

114114
[badge:plugin-homepage]: https://img.shields.io/badge/Plugin%20Home-Leetcode%20Editor-blue?logo=jetbrains&style=flat-square
115115
[badge:plugin-homepage-pro]: https://img.shields.io/badge/Pro%20Plugin%20Home-Leetcode%20Editor%20Pro-blue?logo=jetbrains&style=flat-square&color=blueviolet
116-
[badge:release]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Release?style=flat-square&logo=github&label=Release%20Build
117-
[badge:snapshot]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Snapshot?style=flat-square&logo=github&label=Snapshot%20Build
116+
[badge:release]: https://img.shields.io/github/actions/workflow/status/shuzijun/leetcode-editor/release.yml?branch=master&style=flat-square&logo=github&&label=Release%20Build
117+
[badge:snapshot]: https://img.shields.io/github/actions/workflow/status/shuzijun/leetcode-editor/snapshot.yml?branch=master&style=flat-square&logo=github&&label=Snapshot%20Build
118118
[badge:license]: https://img.shields.io/github/license/shuzijun/leetcode-editor.svg?style=flat-square&&label=License
119119
[badge:downloads]: https://img.shields.io/jetbrains/plugin/d/12132?style=flat-square&label=Plugin%20Downloads&logo=jetbrains
120120
[badge:version]: https://img.shields.io/jetbrains/plugin/v/12132?label=Plugin%20Version&logo=jetbrains&style=flat-square

src/main/java/com/shuzijun/leetcode/plugin/manager/SubmissionManager.java

+25-15
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public static File openSubmission(Submission submission, String titleSlug, Proje
102102
sb.append(codeTypeEnum.getComment()).append("input_formatted:").append(submissionData.getString("input_formatted")).append("\n");
103103
sb.append(codeTypeEnum.getComment()).append("expected_output:").append(submissionData.getString("expected_output")).append("\n");
104104
sb.append(codeTypeEnum.getComment()).append("code_output:").append(submissionData.getString("code_output")).append("\n");
105+
sb.append(codeTypeEnum.getComment()).append("last_testcase:").append(submissionData.getString("last_testcase")).append("\n");
105106
} else if ("Runtime Error".equals(submission.getStatus())) {
106107
sb.append(codeTypeEnum.getComment()).append("runtime_error:").append(submissionData.getString("runtime_error")).append("\n");
107108
sb.append(codeTypeEnum.getComment()).append("last_testcase:").append(submissionData.getString("last_testcase").replaceAll("(\\r|\\r\\n|\\n\\r|\\n)", " ")).append("\n");
@@ -137,21 +138,30 @@ public static File openSubmission(Submission submission, String titleSlug, Proje
137138
}
138139

139140
private static JSONObject loadSubmissionEn(Submission submission, Project project) {
140-
HttpResponse response = HttpRequest.builderGet(URLUtils.getLeetcodeSubmissions() + submission.getId() + "/").request();
141+
HttpResponse response = Graphql.builder().operationName("submissionDetail","submissionDetails").variables("id", submission.getId()).request();
141142
if (response.getStatusCode() == 200) {
142-
String html = response.getBody();
143-
String body = CommentUtils.createSubmissions(html);
144-
if (StringUtils.isBlank(body)) {
145-
LogUtils.LOG.error(html);
146-
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("submission.parse"));
147-
} else {
148-
try {
149-
JSONObject jsonObject = JSONObject.parseObject(body);
150-
return jsonObject;
151-
} catch (Exception e) {
152-
LogUtils.LOG.error(body, e);
153-
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("submission.parse"));
154-
}
143+
String body = response.getBody();
144+
if (StringUtils.isNotBlank(body)) {
145+
JSONObject jsonObject = new JSONObject();
146+
JSONObject enObject = JSONObject.parseObject(body).getJSONObject("data").getJSONObject("submissionDetails");
147+
148+
jsonObject.put("submissionCode", enObject.getString("code"));
149+
150+
JSONObject submissionData = new JSONObject();
151+
submissionData.put("runtime", enObject.getString("runtimeDisplay"));
152+
submissionData.put("memory", enObject.getString("memoryDisplay"));
153+
submissionData.put("total_testcases", "");
154+
submissionData.put("total_correct", "");
155+
submissionData.put("input_formatted", "");
156+
submissionData.put("expected_output", "");
157+
submissionData.put("code_output", "");
158+
submissionData.put("runtime_error", enObject.getString("runtimeError"));
159+
submissionData.put("last_testcase", enObject.getString("lastTestcase"));
160+
submissionData.put("compile_error", enObject.getString("compileError"));
161+
jsonObject.put("submissionData", submissionData);
162+
163+
return jsonObject;
164+
155165
}
156166
} else {
157167
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("request.failed"));
@@ -161,7 +171,7 @@ private static JSONObject loadSubmissionEn(Submission submission, Project projec
161171

162172
private static JSONObject loadSubmissionCn(Submission submission, Project project) {
163173
HttpResponse response = Graphql.builder().cn(URLUtils.isCn()).operationName("submissionDetail").variables("id", submission.getId()).request();
164-
if (response != null && response.getStatusCode() == 200) {
174+
if (response.getStatusCode() == 200) {
165175
String body = response.getBody();
166176
if (StringUtils.isNotBlank(body)) {
167177
JSONObject jsonObject = new JSONObject();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
query submissionDetails($id: Int!) {
2+
submissionDetails(submissionId: $id) {
3+
runtime
4+
runtimeDisplay
5+
runtimePercentile
6+
runtimeDistribution
7+
memory
8+
memoryDisplay
9+
memoryPercentile
10+
memoryDistribution
11+
code
12+
timestamp
13+
statusCode
14+
user {
15+
username
16+
profile {
17+
realName
18+
userAvatar
19+
}
20+
}
21+
lang {
22+
name
23+
verboseName
24+
}
25+
question {
26+
questionId
27+
}
28+
notes
29+
topicTags {
30+
tagId
31+
slug
32+
name
33+
}
34+
runtimeError
35+
compileError
36+
lastTestcase
37+
}
38+
}

0 commit comments

Comments
 (0)