Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@

[badge:plugin-homepage]: https://img.shields.io/badge/Plugin%20Home-Leetcode%20Editor-blue?logo=jetbrains&style=flat-square
[badge:plugin-homepage-pro]: https://img.shields.io/badge/Pro%20Plugin%20Home-Leetcode%20Editor%20Pro-blue?logo=jetbrains&style=flat-square&color=blueviolet
[badge:release]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Release?style=flat-square&logo=github&&label=Release%20Build
[badge:snapshot]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Snapshot?style=flat-square&logo=github&&label=Snapshot%20Build
[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
[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
[badge:license]: https://img.shields.io/github/license/shuzijun/leetcode-editor.svg?style=flat-square&&label=License
[badge:downloads]: https://img.shields.io/jetbrains/plugin/d/12132?style=flat-square&label=Plugin%20Downloads&logo=jetbrains
[badge:version]: https://img.shields.io/jetbrains/plugin/v/12132?label=Plugin%20Version&logo=jetbrains&style=flat-square
Expand Down
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@

[badge:plugin-homepage]: https://img.shields.io/badge/Plugin%20Home-Leetcode%20Editor-blue?logo=jetbrains&style=flat-square
[badge:plugin-homepage-pro]: https://img.shields.io/badge/Pro%20Plugin%20Home-Leetcode%20Editor%20Pro-blue?logo=jetbrains&style=flat-square&color=blueviolet
[badge:release]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Release?style=flat-square&logo=github&label=Release%20Build
[badge:snapshot]: https://img.shields.io/github/workflow/status/shuzijun/leetcode-editor/Snapshot?style=flat-square&logo=github&label=Snapshot%20Build
[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
[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
[badge:license]: https://img.shields.io/github/license/shuzijun/leetcode-editor.svg?style=flat-square&&label=License
[badge:downloads]: https://img.shields.io/jetbrains/plugin/d/12132?style=flat-square&label=Plugin%20Downloads&logo=jetbrains
[badge:version]: https://img.shields.io/jetbrains/plugin/v/12132?label=Plugin%20Version&logo=jetbrains&style=flat-square
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static File openSubmission(Submission submission, String titleSlug, Proje
sb.append(codeTypeEnum.getComment()).append("input_formatted:").append(submissionData.getString("input_formatted")).append("\n");
sb.append(codeTypeEnum.getComment()).append("expected_output:").append(submissionData.getString("expected_output")).append("\n");
sb.append(codeTypeEnum.getComment()).append("code_output:").append(submissionData.getString("code_output")).append("\n");
sb.append(codeTypeEnum.getComment()).append("last_testcase:").append(submissionData.getString("last_testcase")).append("\n");
} else if ("Runtime Error".equals(submission.getStatus())) {
sb.append(codeTypeEnum.getComment()).append("runtime_error:").append(submissionData.getString("runtime_error")).append("\n");
sb.append(codeTypeEnum.getComment()).append("last_testcase:").append(submissionData.getString("last_testcase").replaceAll("(\\r|\\r\\n|\\n\\r|\\n)", " ")).append("\n");
Expand Down Expand Up @@ -137,21 +138,30 @@ public static File openSubmission(Submission submission, String titleSlug, Proje
}

private static JSONObject loadSubmissionEn(Submission submission, Project project) {
HttpResponse response = HttpRequest.builderGet(URLUtils.getLeetcodeSubmissions() + submission.getId() + "/").request();
HttpResponse response = Graphql.builder().operationName("submissionDetail","submissionDetails").variables("id", submission.getId()).request();
if (response.getStatusCode() == 200) {
String html = response.getBody();
String body = CommentUtils.createSubmissions(html);
if (StringUtils.isBlank(body)) {
LogUtils.LOG.error(html);
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("submission.parse"));
} else {
try {
JSONObject jsonObject = JSONObject.parseObject(body);
return jsonObject;
} catch (Exception e) {
LogUtils.LOG.error(body, e);
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("submission.parse"));
}
String body = response.getBody();
if (StringUtils.isNotBlank(body)) {
JSONObject jsonObject = new JSONObject();
JSONObject enObject = JSONObject.parseObject(body).getJSONObject("data").getJSONObject("submissionDetails");

jsonObject.put("submissionCode", enObject.getString("code"));

JSONObject submissionData = new JSONObject();
submissionData.put("runtime", enObject.getString("runtimeDisplay"));
submissionData.put("memory", enObject.getString("memoryDisplay"));
submissionData.put("total_testcases", "");
submissionData.put("total_correct", "");
submissionData.put("input_formatted", "");
submissionData.put("expected_output", "");
submissionData.put("code_output", "");
submissionData.put("runtime_error", enObject.getString("runtimeError"));
submissionData.put("last_testcase", enObject.getString("lastTestcase"));
submissionData.put("compile_error", enObject.getString("compileError"));
jsonObject.put("submissionData", submissionData);

return jsonObject;

}
} else {
MessageUtils.getInstance(project).showWarnMsg("error", PropertiesUtils.getInfo("request.failed"));
Expand All @@ -161,7 +171,7 @@ private static JSONObject loadSubmissionEn(Submission submission, Project projec

private static JSONObject loadSubmissionCn(Submission submission, Project project) {
HttpResponse response = Graphql.builder().cn(URLUtils.isCn()).operationName("submissionDetail").variables("id", submission.getId()).request();
if (response != null && response.getStatusCode() == 200) {
if (response.getStatusCode() == 200) {
String body = response.getBody();
if (StringUtils.isNotBlank(body)) {
JSONObject jsonObject = new JSONObject();
Expand Down
38 changes: 38 additions & 0 deletions src/main/resources/graphql/submissionDetail.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
query submissionDetails($id: Int!) {
submissionDetails(submissionId: $id) {
runtime
runtimeDisplay
runtimePercentile
runtimeDistribution
memory
memoryDisplay
memoryPercentile
memoryDistribution
code
timestamp
statusCode
user {
username
profile {
realName
userAvatar
}
}
lang {
name
verboseName
}
question {
questionId
}
notes
topicTags {
tagId
slug
name
}
runtimeError
compileError
lastTestcase
}
}