refactor fix
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "40m";
|
||||
OnUnitActiveSec = "24h";
|
||||
OnUnitActiveSec = "12h";
|
||||
Unit = "nx_cal_dicos.service";
|
||||
};
|
||||
};
|
||||
@@ -26,9 +26,9 @@ from ics.event import datetime
|
||||
NETTO_STUNDE = 18.46
|
||||
WEEKLY = 12
|
||||
|
||||
week_dict = {}
|
||||
latest_week = 0
|
||||
latest_goal = WEEKLY
|
||||
# week_dict = {}
|
||||
# latest_week = 0
|
||||
# latest_goal = WEEKLY
|
||||
deficit = 0
|
||||
|
||||
def fraction_to_unicode(frac):
|
||||
@@ -51,10 +51,10 @@ def fraction_to_unicode(frac):
|
||||
|
||||
def modify_event(event):
|
||||
"""Modify the event if it contains 'DICOS' in the SUMMARY."""
|
||||
global week_dict
|
||||
global latest_goal
|
||||
global latest_week
|
||||
global deficit
|
||||
# global week_dict
|
||||
# global latest_goal
|
||||
# global latest_week
|
||||
# global deficit
|
||||
|
||||
if event.name is not None and "DICOS" in event.name:
|
||||
length = (event.end - event.begin).seconds / 3600
|
||||
@@ -63,20 +63,20 @@ def modify_event(event):
|
||||
# Calculate total hours for DICOS events in the same week
|
||||
year, week, _ = event.begin.isocalendar()
|
||||
|
||||
if week != latest_week:
|
||||
try:
|
||||
deficit = latest_goal - week_dict[f"{year}_{latest_week}"]
|
||||
except KeyError:
|
||||
deficit = 0
|
||||
# if week != latest_week:
|
||||
# try:
|
||||
# deficit = latest_goal - week_dict[f"{year}_{latest_week}"]
|
||||
# except KeyError:
|
||||
# deficit = 0
|
||||
|
||||
week_dict[f"{year}_{week}"] = length + (week_dict[f"{year}_{week}"] if f"{year}_{week}" in week_dict else 0)
|
||||
# week_dict[f"{year}_{week}"] = length + (week_dict[f"{year}_{week}"] if f"{year}_{week}" in week_dict else 0)
|
||||
|
||||
progress = week_dict[f"{year}_{week}"]
|
||||
goal = WEEKLY + deficit
|
||||
# progress = week_dict[f"{year}_{week}"]
|
||||
# goal = WEEKLY + deficit
|
||||
|
||||
if week != latest_week:
|
||||
latest_goal = goal
|
||||
latest_week = week
|
||||
# if week != latest_week:
|
||||
# latest_goal = goal
|
||||
# latest_week = week
|
||||
|
||||
try:
|
||||
new_description = [event.description.split("\n")[0]]
|
||||
@@ -84,8 +84,8 @@ def modify_event(event):
|
||||
new_description = ["::"]
|
||||
new_description.append("")
|
||||
new_description.append(f"Netto: {money_made[0]:.0f},{int(money_made[1] * 10):02d}€")
|
||||
new_description.append(f"This weeks porgress: ({fraction_to_unicode(progress)}/{fraction_to_unicode(goal)})")
|
||||
new_description.append(f"You're {fraction_to_unicode(abs(deficit))}h in the {'plus' if deficit < 0 else 'minus'} this week.")
|
||||
# new_description.append(f"This weeks porgress: ({fraction_to_unicode(progress)}/{fraction_to_unicode(goal)})")
|
||||
# new_description.append(f"You're {fraction_to_unicode(abs(deficit))}h in the {'plus' if deficit < 0 else 'minus'} this week.")
|
||||
|
||||
event.description = "\n".join(new_description)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
# appendConfig = '''';
|
||||
clientMaxBodySize = "20m";
|
||||
defaultHTTPListenPort = 80;
|
||||
defaultListenAddresses = [ "0.0.0.0" ] ++ lib.optional config.networking.enableIPv6 "[::0]";
|
||||
defaultListenAddresses = [ "0.0.0.0" ] ++ pkgs.lib.optional config.networking.enableIPv6 "[::0]";
|
||||
defaultListen = dl;
|
||||
defaultMimeTypes = "${pkgs.mailcap}/etc/nginx/mime.types";
|
||||
defaultSSLListenPort = 443;
|
||||
|
||||
Reference in New Issue
Block a user