|
1 | 1 | const axios = require('axios'); |
2 | 2 | const { Octokit } = require('@octokit/rest'); |
3 | 3 |
|
4 | | -const COMMIT_MESSAGE = '[LeetCode Sync]'; |
| 4 | +const COMMIT_MESSAGE = 'Sync LeetCode submission'; |
5 | 5 | const LANG_TO_EXTENSION = { |
6 | 6 | 'bash': 'sh', |
7 | 7 | 'c': 'c', |
@@ -34,6 +34,9 @@ function log(message) { |
34 | 34 | } |
35 | 35 |
|
36 | 36 | function pad(n) { |
| 37 | + if (n.length > 4) { |
| 38 | + return n; |
| 39 | + } |
37 | 40 | var s = '000' + n; |
38 | 41 | return s.substring(s.length-4); |
39 | 42 | } |
@@ -74,7 +77,7 @@ async function getInfo(submission, session, csrf) { |
74 | 77 | const questionId = pad(response.data.data.submissionDetails.question.questionId.toString()); |
75 | 78 |
|
76 | 79 | log(`Got info for submission #${submission.id}`); |
77 | | - return { runtimeperc: runtimePercentile, memoryperc: memoryPercentile, qid: questionId }; |
| 80 | + return { runtimePerc: runtimePercentile, memoryPerc: memoryPercentile, qid: questionId }; |
78 | 81 | } catch (exception) { |
79 | 82 | if (retryCount >= maxRetries) { |
80 | 83 | throw exception; |
@@ -114,8 +117,8 @@ async function commit(params) { |
114 | 117 | const prefix = !!destinationFolder ? `${destinationFolder}/` : ''; |
115 | 118 | const commitName = !!commitHeader ? commitHeader : COMMIT_MESSAGE; |
116 | 119 |
|
117 | | - if ('runtimeperc' in submission) { |
118 | | - message = `${commitName} Runtime - ${submission.runtime} (${submission.runtimeperc}), Memory - ${submission.memory} (${submission.memoryperc})`; |
| 120 | + if ('runtimePerc' in submission) { |
| 121 | + message = `${commitName} Runtime - ${submission.runtime} (${submission.runtimePerc}), Memory - ${submission.memory} (${submission.memoryPerc})`; |
119 | 122 | qid = `${submission.qid}-`; |
120 | 123 | } else { |
121 | 124 | message = `${commitName} Runtime - ${submission.runtime}, Memory - ${submission.memory}`; |
|
0 commit comments