chore: code formatting

This commit is contained in:
github-actions[bot]
2022-04-23 23:18:43 +00:00
parent 73cd43c18f
commit 4c98629bbc
130 changed files with 1839 additions and 1788 deletions

View File

@@ -7,30 +7,30 @@ export default async function({login, q, imports, data, account}, {enabled = fal
return null
//Load inputs
let {sections, days, limit, url, user, "languages.other":others} = imports.metadata.plugins.wakatime.inputs({data, account, q})
let {sections, days, limit, url, user, "languages.other": others} = imports.metadata.plugins.wakatime.inputs({data, account, q})
if (!limit)
limit = void limit
const range = {
"7":"last_7_days",
"30":"last_30_days",
"180":"last_6_months",
"365":"last_year",
"7": "last_7_days",
"30": "last_30_days",
"180": "last_6_months",
"365": "last_year",
}[days] ?? "last_7_days"
//Querying api and format result (https://wakatime.com/developers#stats)
console.debug(`metrics/compute/${login}/plugins > wakatime > querying api`)
const {data:{data:stats}} = await imports.axios.get(`${url}/api/v1/users/${user}/stats/${range}?api_key=${token}`)
const {data: {data: stats}} = await imports.axios.get(`${url}/api/v1/users/${user}/stats/${range}?api_key=${token}`)
const result = {
sections,
days,
time:{
total:(others ? stats.total_seconds_including_other_language : stats.total_seconds) / (60 * 60),
daily:(others ? stats.daily_average_including_other_language : stats.daily_average) / (60 * 60),
time: {
total: (others ? stats.total_seconds_including_other_language : stats.total_seconds) / (60 * 60),
daily: (others ? stats.daily_average_including_other_language : stats.daily_average) / (60 * 60),
},
projects:stats.projects?.map(({name, percent, total_seconds:total}) => ({name, percent:percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
languages:stats.languages?.map(({name, percent, total_seconds:total}) => ({name, percent:percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
os:stats.operating_systems?.map(({name, percent, total_seconds:total}) => ({name, percent:percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
editors:stats.editors?.map(({name, percent, total_seconds:total}) => ({name, percent:percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
projects: stats.projects?.map(({name, percent, total_seconds: total}) => ({name, percent: percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
languages: stats.languages?.map(({name, percent, total_seconds: total}) => ({name, percent: percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
os: stats.operating_systems?.map(({name, percent, total_seconds: total}) => ({name, percent: percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
editors: stats.editors?.map(({name, percent, total_seconds: total}) => ({name, percent: percent / 100, total})).sort((a, b) => b.percent - a.percent).slice(0, limit),
}
//Result
@@ -44,6 +44,6 @@ export default async function({login, q, imports, data, account}, {enabled = fal
message = `API returned ${status}`
error = error.response?.data ?? null
}
throw {error:{message, instance:error}}
throw {error: {message, instance: error}}
}
}