Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clockify

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockify - npm Package Compare versions

Comparing version 0.9.6 to 0.10.6

35

bin/model.js

@@ -100,2 +100,3 @@ "use strict";

if (respData.length == 0) {
// @ts-ignore
respData = "activity not found";

@@ -121,3 +122,2 @@ }

}
// @ts-ignore
const onelineEntries = resp.data.map((itemObj) => {

@@ -361,2 +361,34 @@ let onelineItem = [];

}
const getStats = (activity) => __awaiter(void 0, void 0, void 0, function* () {
const resp = yield (0, db_1.default)("select * from events;", []);
if (resp.err) {
console.log(resp);
return resp;
}
const year = new Date(resp.data[0].date).getFullYear();
const cal = utils_1.default.generateCalendar(year);
const monthNames = Object.keys(cal);
let previousMonthNumber = undefined;
resp.data.forEach((event, index, arr) => {
const { date, duration } = event;
const durationHours = event.duration / 60 / 60;
const eventMonth = new Date(date).getMonth();
const eventDay = new Date(date).getDate();
// console.log(eventMonth, monthNames[eventMonth], cal[monthNames[eventMonth]]);
// console.log(eventDay, cal[monthNames[eventMonth]].days[eventDay - 1]);
cal[monthNames[eventMonth]].duration += durationHours;
cal[monthNames[eventMonth]].days[eventDay - 1].hours += durationHours;
const isNextMonth = eventMonth !== previousMonthNumber;
const isLastEvent = index == arr.length - 1;
if (previousMonthNumber !== undefined && (isNextMonth || isLastEvent)) {
cal[monthNames[previousMonthNumber]].fullDate =
`${year}-${previousMonthNumber + 1}-${eventDay}`;
const hoursPerDay = cal[monthNames[previousMonthNumber]].duration /
cal[monthNames[previousMonthNumber]].days.length;
cal[monthNames[previousMonthNumber]].hoursPerDay = hoursPerDay;
}
previousMonthNumber = eventMonth;
});
return { err: false, data: cal };
});
const getDayDuration = (_, activity) => __awaiter(void 0, void 0, void 0, function* () {

@@ -418,3 +450,4 @@ // was fixing date format in db

getDuration,
getStats,
incrementDuration,
};

@@ -36,3 +36,3 @@ "use strict";

const incrementDuration = () => {
// interval is passed as seconds
// seconds
const duration = Math.floor((Date.now() - timerObj.startDate) / 1000);

@@ -88,2 +88,3 @@ // console.log(duration);

da: ["da - get duration of all activities", " d [d, w, m]"],
p: ["p - print stats", " p [activity]"],
v: "v - get status",

@@ -194,2 +195,25 @@ s: "s - toggle timer",

}),
p: (socket, request) => __awaiter(void 0, void 0, void 0, function* () {
const activity = (request === null || request === void 0 ? void 0 : request.args[0]) || timerObj.currentActivity || undefined;
if (!activity) {
return;
}
const resp = yield model_1.default.getStats(activity);
if (resp.err) {
socket.write(JSON.stringify({ err: resp.err }));
return;
}
let data = "";
Object.entries(resp.data).forEach((month) => {
const [monthName, monthData] = month;
data += `\n${monthName}: ${utils_1.default.secToTime(monthData.duration * 60 * 60)} | ${monthData.hoursPerDay.toFixed(2)} hours per day`;
if (monthData.duration > 0) {
monthData.days.forEach((day, index) => {
data += `\n [${index + 1}] ${day.hours.toFixed(2)} hours`;
});
}
});
socket.write(JSON.stringify({ err: false, data }));
utils_1.default.notify("activities duration", data, "green");
}),
// duration of all activities

@@ -196,0 +220,0 @@ da: (socket, request) => __awaiter(void 0, void 0, void 0, function* () {

@@ -111,2 +111,16 @@ "use strict";

};
function generateCalendar(year) {
const calendar = {};
for (let month = 0; month < 12; month++) {
const lastDay = new Date(year, month + 1, 0).getDate();
const monthName = new Date(year, month).toLocaleString("default", { month: "long" });
calendar[monthName] = {
duration: 0,
hoursPerDay: 0,
fullDate: "",
days: Array.from({ length: lastDay }, (_, i) => ({ hours: 0 })),
};
}
return calendar;
}
exports.default = {

@@ -122,2 +136,3 @@ notify,

debug,
generateCalendar,
};

2

package.json
{
"name": "clockify",
"version": "0.9.6",
"version": "0.10.6",
"description": "A time tracker to make sure that you really spent the time you think you spent working, studying, etc.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc