chore: code formatting
This commit is contained in:
@@ -1022,23 +1022,23 @@
|
|||||||
user: options["leetcode.user"],
|
user: options["leetcode.user"],
|
||||||
sections: options["leetcode.sections"].split(",").map(x => x.trim()).filter(x => x),
|
sections: options["leetcode.sections"].split(",").map(x => x.trim()).filter(x => x),
|
||||||
languages: new Array(6).fill(null).map(_ => ({
|
languages: new Array(6).fill(null).map(_ => ({
|
||||||
language:faker.hacker.noun(),
|
language: faker.hacker.noun(),
|
||||||
solved:faker.datatype.number(200)
|
solved: faker.datatype.number(200),
|
||||||
})),
|
})),
|
||||||
skills: new Array(Number(options["leetcode.limit.skills"]) || 10).fill(null).map(_ => ({
|
skills: new Array(Number(options["leetcode.limit.skills"]) || 10).fill(null).map(_ => ({
|
||||||
name:faker.hacker.noun(),
|
name: faker.hacker.noun(),
|
||||||
category:faker.helpers.arrayElement(["advanced", "intermediate", "fundamental"]),
|
category: faker.helpers.arrayElement(["advanced", "intermediate", "fundamental"]),
|
||||||
solved:faker.datatype.number(30)
|
solved: faker.datatype.number(30),
|
||||||
})),
|
})),
|
||||||
problems: {
|
problems: {
|
||||||
All: { count: 2402, solved: faker.datatype.number(2402) },
|
All: {count: 2402, solved: faker.datatype.number(2402)},
|
||||||
Easy: { count: 592, solved: faker.datatype.number(592) },
|
Easy: {count: 592, solved: faker.datatype.number(592)},
|
||||||
Medium: { count: 1283, solved: faker.datatype.number(1283) },
|
Medium: {count: 1283, solved: faker.datatype.number(1283)},
|
||||||
Hard: { count: 527, solved: faker.datatype.number(527) }
|
Hard: {count: 527, solved: faker.datatype.number(527)},
|
||||||
},
|
},
|
||||||
recent: new Array(Number(options["leetcode.limit.recent"]) || 2).fill(null).map(_ => ({
|
recent: new Array(Number(options["leetcode.limit.recent"]) || 2).fill(null).map(_ => ({
|
||||||
title:faker.lorem.sentence(),
|
title: faker.lorem.sentence(),
|
||||||
date:faker.date.recent(),
|
date: faker.date.recent(),
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default async function({login, graphql, rest, data, q, queries, imports,
|
|||||||
console.debug(`metrics/compute/${login}/base > affiliations constraints ${affiliations}`)
|
console.debug(`metrics/compute/${login}/base > affiliations constraints ${affiliations}`)
|
||||||
|
|
||||||
//Skip initial data gathering if not needed
|
//Skip initial data gathering if not needed
|
||||||
if ((conf.settings.notoken)||(skip)) {
|
if ((conf.settings.notoken) || (skip)) {
|
||||||
await callbacks?.plugin?.(login, "base", true, data).catch(error => console.debug(`metrics/compute/${login}/plugins/callbacks > base > ${error}`))
|
await callbacks?.plugin?.(login, "base", true, data).catch(error => console.debug(`metrics/compute/${login}/plugins/callbacks > base > ${error}`))
|
||||||
return (postprocess.skip({login, data, imports}), {})
|
return (postprocess.skip({login, data, imports}), {})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,22 +7,22 @@ export default async function({login, q, imports, data, queries, account}, {enab
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {user, sections, "limit.skills":_limit_skills, "limit.recent":_limit_recent} = imports.metadata.plugins.leetcode.inputs({data, account, q})
|
let {user, sections, "limit.skills": _limit_skills, "limit.recent": _limit_recent} = imports.metadata.plugins.leetcode.inputs({data, account, q})
|
||||||
const result = {user, sections, languages:[], skills:[], problems:{}, recent:[]}
|
const result = {user, sections, languages: [], skills: [], problems: {}, recent: []}
|
||||||
|
|
||||||
//Languages stats
|
//Languages stats
|
||||||
{
|
{
|
||||||
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (languages statistics)`)
|
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (languages statistics)`)
|
||||||
const {data:{data:{matchedUser:{languageProblemCount:languages}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.languages()})
|
const {data: {data: {matchedUser: {languageProblemCount: languages}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.languages()})
|
||||||
result.languages = languages.map(({languageName:language, problemsSolved:solved}) => ({language, solved}))
|
result.languages = languages.map(({languageName: language, problemsSolved: solved}) => ({language, solved}))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Skills stats
|
//Skills stats
|
||||||
{
|
{
|
||||||
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (skills statistics)`)
|
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (skills statistics)`)
|
||||||
const {data:{data:{matchedUser:{tagProblemCounts:skills}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.skills()})
|
const {data: {data: {matchedUser: {tagProblemCounts: skills}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.skills()})
|
||||||
for (const category in skills)
|
for (const category in skills)
|
||||||
result.skills.push(...skills[category].map(({tagName:name, problemsSolved:solved}) => ({name, solved, category})))
|
result.skills.push(...skills[category].map(({tagName: name, problemsSolved: solved}) => ({name, solved, category})))
|
||||||
result.skills.sort((a, b) => b.solved - a.solved)
|
result.skills.sort((a, b) => b.solved - a.solved)
|
||||||
result.skills = result.skills.slice(0, _limit_skills || Infinity)
|
result.skills = result.skills.slice(0, _limit_skills || Infinity)
|
||||||
}
|
}
|
||||||
@@ -30,18 +30,18 @@ export default async function({login, q, imports, data, queries, account}, {enab
|
|||||||
//Problems
|
//Problems
|
||||||
{
|
{
|
||||||
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (problems statistics)`)
|
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (problems statistics)`)
|
||||||
const {data:{data:{allQuestionsCount:all, matchedUser:{submitStatsGlobal:{acSubmissionNum:submissions}}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.problems()})
|
const {data: {data: {allQuestionsCount: all, matchedUser: {submitStatsGlobal: {acSubmissionNum: submissions}}}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user}, query: queries.leetcode.problems()})
|
||||||
for (const {difficulty, count} of all)
|
for (const {difficulty, count} of all)
|
||||||
result.problems[difficulty] = {count, solved:0}
|
result.problems[difficulty] = {count, solved: 0}
|
||||||
for (const {difficulty, count:solved} of submissions)
|
for (const {difficulty, count: solved} of submissions)
|
||||||
result.problems[difficulty].solved = solved
|
result.problems[difficulty].solved = solved
|
||||||
}
|
}
|
||||||
|
|
||||||
//Recent submissions
|
//Recent submissions
|
||||||
{
|
{
|
||||||
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (recent submissions statistics)`)
|
console.debug(`metrics/compute/${login}/plugins > leetcode > querying api (recent submissions statistics)`)
|
||||||
const {data:{data:{recentAcSubmissionList:submissions}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user, limit:_limit_recent}, query: queries.leetcode.recent()})
|
const {data: {data: {recentAcSubmissionList: submissions}}} = await imports.axios.post("https://leetcode.com/graphql", {variables: {username: user, limit: _limit_recent}, query: queries.leetcode.recent()})
|
||||||
result.recent = submissions.map(({title, timestamp}) => ({title, date:new Date(timestamp*1000)}))
|
result.recent = submissions.map(({title, timestamp}) => ({title, date: new Date(timestamp * 1000)}))
|
||||||
}
|
}
|
||||||
|
|
||||||
//Results
|
//Results
|
||||||
@@ -51,4 +51,4 @@ export default async function({login, q, imports, data, queries, account}, {enab
|
|||||||
catch (error) {
|
catch (error) {
|
||||||
throw imports.format.error(error)
|
throw imports.format.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
|||||||
status: 200,
|
status: 200,
|
||||||
data: {
|
data: {
|
||||||
data: {
|
data: {
|
||||||
matchedUser:{
|
matchedUser: {
|
||||||
languageProblemCount:new Array(6).fill(null).map(_ => ({
|
languageProblemCount: new Array(6).fill(null).map(_ => ({
|
||||||
languageName:faker.hacker.noun(),
|
languageName: faker.hacker.noun(),
|
||||||
problemsSolved:faker.datatype.number(200)
|
problemsSolved: faker.datatype.number(200),
|
||||||
}))
|
})),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -26,25 +26,25 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
|||||||
status: 200,
|
status: 200,
|
||||||
data: {
|
data: {
|
||||||
data: {
|
data: {
|
||||||
matchedUser:{
|
matchedUser: {
|
||||||
tagProblemCounts:{
|
tagProblemCounts: {
|
||||||
advanced:new Array(6).fill(null).map(_ => ({
|
advanced: new Array(6).fill(null).map(_ => ({
|
||||||
tagName:faker.hacker.noun(),
|
tagName: faker.hacker.noun(),
|
||||||
tagSlug:faker.lorem.slug(),
|
tagSlug: faker.lorem.slug(),
|
||||||
problemsSolved:faker.datatype.number(200)
|
problemsSolved: faker.datatype.number(200),
|
||||||
})),
|
})),
|
||||||
intermediate:new Array(6).fill(null).map(_ => ({
|
intermediate: new Array(6).fill(null).map(_ => ({
|
||||||
tagName:faker.hacker.noun(),
|
tagName: faker.hacker.noun(),
|
||||||
tagSlug:faker.lorem.slug(),
|
tagSlug: faker.lorem.slug(),
|
||||||
problemsSolved:faker.datatype.number(200)
|
problemsSolved: faker.datatype.number(200),
|
||||||
})),
|
})),
|
||||||
fundamental:new Array(6).fill(null).map(_ => ({
|
fundamental: new Array(6).fill(null).map(_ => ({
|
||||||
tagName:faker.hacker.noun(),
|
tagName: faker.hacker.noun(),
|
||||||
tagSlug:faker.lorem.slug(),
|
tagSlug: faker.lorem.slug(),
|
||||||
problemsSolved:faker.datatype.number(200)
|
problemsSolved: faker.datatype.number(200),
|
||||||
}))
|
})),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -56,27 +56,27 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
|||||||
status: 200,
|
status: 200,
|
||||||
data: {
|
data: {
|
||||||
data: {
|
data: {
|
||||||
allQuestionsCount:[
|
allQuestionsCount: [
|
||||||
{difficulty:"All", count:2402},
|
{difficulty: "All", count: 2402},
|
||||||
{difficulty:"Easy", count:592},
|
{difficulty: "Easy", count: 592},
|
||||||
{difficulty:"Medium", count:1283},
|
{difficulty: "Medium", count: 1283},
|
||||||
{difficulty:"Hard", count:527},
|
{difficulty: "Hard", count: 527},
|
||||||
],
|
],
|
||||||
matchedUser:{
|
matchedUser: {
|
||||||
problemsSolvedBeatsStats:[
|
problemsSolvedBeatsStats: [
|
||||||
{difficulty:"Easy", percentage:faker.datatype.float({max:100})},
|
{difficulty: "Easy", percentage: faker.datatype.float({max: 100})},
|
||||||
{difficulty:"Medium", percentage:faker.datatype.float({max:100})},
|
{difficulty: "Medium", percentage: faker.datatype.float({max: 100})},
|
||||||
{difficulty:"Hard", percentage:faker.datatype.float({max:100})},
|
{difficulty: "Hard", percentage: faker.datatype.float({max: 100})},
|
||||||
],
|
],
|
||||||
submitStatsGlobal:{
|
submitStatsGlobal: {
|
||||||
acSubmissionNum:[
|
acSubmissionNum: [
|
||||||
{difficulty:"All", count:faker.datatype.number(2402)},
|
{difficulty: "All", count: faker.datatype.number(2402)},
|
||||||
{difficulty:"Easy", count:faker.datatype.number(592)},
|
{difficulty: "Easy", count: faker.datatype.number(592)},
|
||||||
{difficulty:"Medium", count:faker.datatype.number(1283)},
|
{difficulty: "Medium", count: faker.datatype.number(1283)},
|
||||||
{difficulty:"Hard", count:faker.datatype.number(527)},
|
{difficulty: "Hard", count: faker.datatype.number(527)},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -88,11 +88,11 @@ export default function({faker, url, body, login = faker.internet.userName()}) {
|
|||||||
status: 200,
|
status: 200,
|
||||||
data: {
|
data: {
|
||||||
data: {
|
data: {
|
||||||
recentAcSubmissionList:new Array(6).fill(null).map(_ => ({
|
recentAcSubmissionList: new Array(6).fill(null).map(_ => ({
|
||||||
id:`${faker.datatype.number(10000)}`,
|
id: `${faker.datatype.number(10000)}`,
|
||||||
title:faker.lorem.sentence(),
|
title: faker.lorem.sentence(),
|
||||||
titleSlug:faker.lorem.slug(),
|
titleSlug: faker.lorem.slug(),
|
||||||
timestamp:`${Math.round(faker.date.recent().getTime()/1000)}`,
|
timestamp: `${Math.round(faker.date.recent().getTime() / 1000)}`,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user