Skip to content

Commit

Permalink
refactor: stats
Browse files Browse the repository at this point in the history
  • Loading branch information
dvgamerr committed Mar 9, 2024
1 parent f4533ea commit 3021d81
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
9 changes: 6 additions & 3 deletions collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
const args = arg({
'--github': Boolean,
'--wakatime': Boolean,
'--file': String,
});

const enableGithub = args['--github'] && process.env.GH_TOKEN
Expand Down Expand Up @@ -185,8 +186,6 @@ const collectWakaTime = async () => {
coding.average_seconds += totalDuration
if (i > idx - 7) {
coding.weekly_seconds += totalDuration

dateDuration
}
if (coding.best_seconds < totalDuration) coding.best_seconds = totalDuration

Expand All @@ -203,8 +202,12 @@ const collectWakaTime = async () => {
coding.weekly_seconds = coding.weekly_seconds / 7
coding.weektime = coding.weektime.map(e => e.duration / e.count)

if (!args['--file']) {
delete coding.daytime
}
logger.debug(coding)

await mergeJsonResponse(coding, './src/i18n/coding.json')
await mergeJsonResponse(body, './src/i18n/insights.json')

// for (let i = totalDay; i >= 0; i--) {
Expand Down Expand Up @@ -281,7 +284,7 @@ const getCitibankUSD = async () => {
}

Initializes().then(() => Promise.all([
// collectGithubProjectStats(),
collectGithubProjectStats(),
getCitibankUSD(),
collectWakaTime(),
])).then((res) => {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"collector:gh": "node ./collector/index.js --github | pino-pretty",
"collector:wk": "node ./collector/index.js --wakatime --file D:/home/Downloads/wakatime-info.dvgamergmail.com-06633b1c3ba744c2ab5d08e47ccc87ab.json | pino-pretty",
"collector": "node ./collector/index.js --wakatime --github | pino-pretty",
"astro": "astro"
},
Expand Down
12 changes: 6 additions & 6 deletions src/i18n/coding.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"total": 219,
"private": 3,
"private": 49,
"public": 216,
"languages": [
"JavaScript",
Expand Down Expand Up @@ -53,9 +53,9 @@
"commits": 3453,
"experience": "2013-04-29T00:00:00.000+07:00",
"updated": "2024-03-06T10:15:42.843Z",
"weekly_seconds": 7317.49946,
"average_seconds": 7058.645887263014,
"best_seconds": 44422.207450999995,
"weekly_seconds": 17421.754013714286,
"average_seconds": 7098.943936191781,
"best_seconds": 46975.804539,
"loc": 0,
"daytime": [
69,
Expand Down Expand Up @@ -86,8 +86,8 @@
"weektime": [
7387.844356711541,
10491.952919365383,
8996.180162358487,
9303.651937615385,
9188.293258788459,
9173.31216245283,
6895.8477763461515,
3726.3331686538468,
2789.1322143653842
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/experience.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"currencry": {
"ccy": "USD",
"sell": 35.92,
"buy": 35.41
"buy": 35.3
},
"salary": {
"base": 71950,
Expand Down
32 changes: 16 additions & 16 deletions src/i18n/insights.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{
"data": {
"days": [
{
"date": "2023-03-08",
"total": 521.075104,
"categories": [
{
"name": "Coding",
"total": 521.075104
},
{
"name": "Debugging",
"total": 0
}
]
},
{
"date": "2023-03-09",
"total": 5845.748157,
Expand Down Expand Up @@ -5099,11 +5085,25 @@
},
{
"date": "2024-03-06",
"total": 30262.969648,
"total": 31777.745604,
"categories": [
{
"name": "Coding",
"total": 31777.745604
},
{
"name": "Debugging",
"total": 0
}
]
},
{
"date": "2024-03-07",
"total": 2395.643854,
"categories": [
{
"name": "Coding",
"total": 30262.969648
"total": 2395.643854
}
]
}
Expand Down

0 comments on commit 3021d81

Please sign in to comment.