hackhours 0.1.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/queries.d.ts +1 -0
- package/dist/analytics/queries.js +6 -8
- package/dist/cli.js +2 -9
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ export type Summary = {
|
|
|
5
5
|
languages: Map<string, number>;
|
|
6
6
|
projects: Map<string, number>;
|
|
7
7
|
activityByHour: number[];
|
|
8
|
+
activityByHourByLanguage: Map<string, number[]>;
|
|
8
9
|
activityByDay: Map<string, number>;
|
|
9
10
|
};
|
|
10
11
|
export declare const buildSummary: (collections: ChronoCollections, from: number, to: number, idleMinutes: number) => Promise<Summary>;
|
|
@@ -22,16 +22,9 @@ export const buildSummary = async (collections, from, to, idleMinutes) => {
|
|
|
22
22
|
languages: new Map(),
|
|
23
23
|
projects: new Map(),
|
|
24
24
|
activityByHour: Array.from({ length: 24 }, () => 0),
|
|
25
|
+
activityByHourByLanguage: new Map(),
|
|
25
26
|
activityByDay: new Map(),
|
|
26
27
|
};
|
|
27
|
-
for (const session of sessions) {
|
|
28
|
-
const sessionEnd = session.endTimestamp ?? now;
|
|
29
|
-
const overlapStart = Math.max(session.startTimestamp, from);
|
|
30
|
-
const overlapEnd = Math.min(sessionEnd, to);
|
|
31
|
-
if (overlapEnd > overlapStart) {
|
|
32
|
-
summary.totalTimeMs += overlapEnd - overlapStart;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
28
|
for (const [sessionId, list] of eventsBySession.entries()) {
|
|
36
29
|
const session = sessionsById.get(sessionId);
|
|
37
30
|
const sessionEnd = session?.endTimestamp ?? now;
|
|
@@ -43,12 +36,17 @@ export const buildSummary = async (collections, from, to, idleMinutes) => {
|
|
|
43
36
|
const duration = Math.max(0, Math.min(nextTs - current.timestamp, idleMs));
|
|
44
37
|
if (duration <= 0)
|
|
45
38
|
continue;
|
|
39
|
+
summary.totalTimeMs += duration;
|
|
46
40
|
addToMap(summary.languages, current.language, duration);
|
|
47
41
|
addToMap(summary.projects, current.project, duration);
|
|
48
42
|
addToMap(summary.filesEdited, current.filePath, duration);
|
|
49
43
|
const eventDate = new Date(current.timestamp);
|
|
50
44
|
const hour = eventDate.getHours();
|
|
51
45
|
summary.activityByHour[hour] += duration;
|
|
46
|
+
if (!summary.activityByHourByLanguage.has(current.language)) {
|
|
47
|
+
summary.activityByHourByLanguage.set(current.language, Array.from({ length: 24 }, () => 0));
|
|
48
|
+
}
|
|
49
|
+
summary.activityByHourByLanguage.get(current.language)[hour] += duration;
|
|
52
50
|
addToMap(summary.activityByDay, toDateKey(eventDate), duration);
|
|
53
51
|
}
|
|
54
52
|
}
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import Table from "cli-table3";
|
|
5
|
-
import * as asciichart from "asciichart";
|
|
6
5
|
import { spawn } from "node:child_process";
|
|
7
6
|
import path from "node:path";
|
|
8
7
|
import process from "node:process";
|
|
@@ -19,6 +18,7 @@ const formatBar = (value, total, size = 16) => {
|
|
|
19
18
|
const filled = Math.round((value / total) * size);
|
|
20
19
|
return `${"█".repeat(filled)}${" ".repeat(size - filled)}`;
|
|
21
20
|
};
|
|
21
|
+
// Charts and history output removed per request.
|
|
22
22
|
const printSummary = (title, summary) => {
|
|
23
23
|
const total = summary.totalTimeMs;
|
|
24
24
|
console.log(chalk.bold(`\n${title}`));
|
|
@@ -35,14 +35,7 @@ const printSummary = (title, summary) => {
|
|
|
35
35
|
}
|
|
36
36
|
console.log(langTable.toString());
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
const series = summary.activityByHour.map((ms) => Math.round(ms / 60000));
|
|
40
|
-
if (series.some((v) => v > 0)) {
|
|
41
|
-
console.log(asciichart.plot(series, { height: 8 }));
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.log("No activity recorded.");
|
|
45
|
-
}
|
|
38
|
+
// Activity chart removed per request.
|
|
46
39
|
};
|
|
47
40
|
const printBreakdown = (title, map, total) => {
|
|
48
41
|
console.log(chalk.bold(`\n${title}`));
|