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

Commit 9195bcf

Browse files
refs skygragon#82: show frontend id in cli.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 9ed9b9a commit 9195bcf

File tree

11 files changed

+21
-18
lines changed

11 files changed

+21
-18
lines changed

‎lib/commands/list.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cmd.handler = function(argv) {
6060
const stat = {};
6161
for (let x of ['locked', 'starred', 'ac', 'notac', 'None', 'Easy', 'Medium', 'Hard']) stat[x] = 0;
6262

63-
problems = _.sortBy(problems, x => -x.id);
63+
problems = _.sortBy(problems, x => -x.fid);
6464
for (let problem of problems) {
6565
stat[problem.level] = (stat[problem.level] || 0) + 1;
6666
stat[problem.state] = (stat[problem.state] || 0) + 1;
@@ -71,7 +71,7 @@ cmd.handler = function(argv) {
7171
(problem.starred ? chalk.yellow(icon.like) : icon.none),
7272
(problem.locked ? chalk.red(icon.lock) : icon.none),
7373
h.prettyState(problem.state),
74-
problem.id,
74+
problem.fid,
7575
problem.name,
7676
h.prettyLevel(sprintf('%-6s', problem.level)),
7777
problem.percent);

‎lib/commands/show.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const cmd = {
7575
function genFileName(problem, opts) {
7676
const path = require('path');
7777
const params = [
78-
problem.id,
78+
problem.fid,
7979
problem.slug,
8080
'',
8181
h.langToExt(opts.lang)
@@ -139,7 +139,7 @@ function showProblem(problem, argv) {
139139
}
140140
}
141141

142-
log.printf('[%d] %s %s', problem.id, problem.name,
142+
log.printf('[%d] %s %s', problem.fid, problem.name,
143143
(problem.starred ? chalk.yellow(icon.like) : icon.none));
144144
log.info();
145145
log.info(chalk.underline(problem.link));

‎lib/commands/star.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cmd.handler = function(argv) {
3535
core.starProblem(problem, !argv.delete, function(e, starred) {
3636
if (e) return log.fail(e);
3737

38-
log.printf('[%d] %s %s', problem.id, problem.name,
38+
log.printf('[%d] %s %s', problem.fid, problem.name,
3939
chalk.yellow(starred ? icon.like : icon.unlike));
4040

4141
core.updateProblem(problem, {starred: starred});

‎lib/commands/stat.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function showGraph(problems) {
106106

107107
const graph = [];
108108
for (let problem of problems)
109-
graph[problem.id] = ICONS[problem.state] || ICONS.none;
109+
graph[problem.fid] = ICONS[problem.state] || ICONS.none;
110110

111111
let line = [sprintf(' %03d', 0)];
112112
for (let i = 1, n = graph.length; i <= n; ++i) {

‎lib/commands/submission.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ function doTask(problem, queue, cb) {
5959
// - green: accepted, fresh download
6060
// - yellow: not ac-ed, fresh download
6161
// - white: existed already, skip download
62-
log.printf('[%3d] %-60s %s', problem.id, problem.name,
62+
log.printf('[%3d] %-60s %s', problem.fid, problem.name,
6363
(e ? chalk.red('ERROR: ' + (e.msg || e)) : msg));
6464
if (cb) cb(e);
6565
}
6666

6767
if (argv.extra) {
6868
// have to get problem details, e.g. problem description.
69-
core.getProblem(problem.id, function(e, problem) {
69+
core.getProblem(problem.fid, function(e, problem) {
7070
if (e) return cb(e);
7171
exportSubmission(problem, argv, onTaskDone);
7272
});
@@ -92,7 +92,7 @@ function exportSubmission(problem, argv, cb) {
9292

9393
const f = sprintf('%s/%d.%s.%s.%s%s',
9494
argv.outdir,
95-
problem.id,
95+
problem.fid,
9696
problem.slug,
9797
submission.id,
9898
submission.ac ? 'ac' : 'notac',

‎lib/commands/submit.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cmd.handler = function(argv) {
6666

6767
if (result.ok) {
6868
session.updateStat('ac', 1);
69-
session.updateStat('ac.set', problem.id);
69+
session.updateStat('ac.set', problem.fid);
7070
core.getSubmission({id: result.id}, function(e, submission) {
7171
if (e || !submission || !submission.distributionChart)
7272
return log.warn('Failed to get submission beat ratio.');

‎lib/core.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ core.getProblem = function(keyword, cb) {
8989

9090
keyword = Number(keyword) || keyword;
9191
const problem = problems.find(function(x) {
92-
return x.id === keyword || x.name === keyword || x.slug === keyword;
92+
return x.fid === keyword || x.name === keyword || x.slug === keyword;
9393
});
9494
if (!problem) return cb('Problem not found!');
9595
core.next.getProblem(problem, cb);

‎lib/helper.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ h.KEYS = {
5454
user: '../user',
5555
stat: '../stat',
5656
problems: 'problems',
57-
problem: p => p.id + '.' + p.slug + '.' + p.category
57+
problem: p => p.fid + '.' + p.slug + '.' + p.category
5858
};
5959

6060
h.isWindows = function() {

‎lib/plugins/leetcode.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ plugin.getCategoryProblems = function(category, cb) {
101101
return {
102102
state: p.status || 'None',
103103
id: p.stat.question_id,
104+
fid: p.stat.frontend_question_id,
104105
name: p.stat.question__title,
105106
slug: p.stat.question__title_slug,
106107
link: config.sys.urls.problem.replace('$slug', p.stat.question__title_slug),

‎test/plugins/test_cache.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const HOME = './tmp';
1818

1919
describe('plugin:cache', function() {
2020
const PROBLEMS = [
21-
{id: 0, name: 'name0', slug: 'slug0', starred: false, category: 'algorithms'},
22-
{id: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
21+
{id: 0, fid: 0,name: 'name0', slug: 'slug0', starred: false, category: 'algorithms'},
22+
{id: 1, fid: 1,name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
2323
];
24-
const PROBLEM = {id: 0, slug: 'slug0', category: 'algorithms'};
24+
const PROBLEM = {id: 0, fid: 0,slug: 'slug0', category: 'algorithms'};
2525

2626
const NEXT = {};
2727

@@ -125,7 +125,7 @@ describe('plugin:cache', function() {
125125
const ret = plugin.saveProblem(problem);
126126
assert.equal(ret, true);
127127
assert.deepEqual(cache.get('0.slug0.algorithms'),
128-
{id: 0, slug: 'slug0', name: 'name0', category: 'algorithms'});
128+
{id: 0, fid: 0,slug: 'slug0', name: 'name0', category: 'algorithms'});
129129
});
130130
}); // #saveProblem
131131

@@ -140,8 +140,8 @@ describe('plugin:cache', function() {
140140
plugin.getProblems(function(e, problems) {
141141
assert.equal(e, null);
142142
assert.deepEqual(problems, [
143-
{id: 0, name: 'name0', slug: 'slug0', value: 'value00', starred: false, category: 'algorithms'},
144-
{id: 1, name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
143+
{id: 0, fid: 0,name: 'name0', slug: 'slug0', value: 'value00', starred: false, category: 'algorithms'},
144+
{id: 1, fid: 1,name: 'name1', slug: 'slug1', starred: true, category: 'algorithms'}
145145
]);
146146
done();
147147
});

0 commit comments

Comments
(0)

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