Created
February 10, 2019 12:31
-
-
Save studentIvan/a1fedf70a1f0abdc11ea9bb2b6708b6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--c--- get multiplier from things todo object | |
on getMultiplierFromToDo(theToDo, defaultMultiplierValue) | |
local theToDo | |
set toDoName to name of theToDo | |
set multiplier to second character of toDoName | |
set multiplierBefore to first character of toDoName | |
set multiplierAfter to third character of toDoName | |
set isValidMultiplier to ((multiplierBefore is equal to "[") and (multiplierAfter is equal to "]")) | |
set multiplierValue to defaultMultiplierValue | |
if isValidMultiplier then set multiplierValue to multiplier as real | |
return multiplierValue | |
end getMultiplierFromToDo | |
--c--- get hours time str as (x часа) | |
on fmtHrsTimeStr(countOf, estimationMinutes) | |
set timeHrs to (countOf * estimationMinutes) / 60 | |
set timeHrsStr to timeHrs as text | |
return "(" & timeHrsStr & " часа)" | |
end fmtHrsTimeStr | |
--c--- get percent text | |
on fmtPercent(percentValue) | |
set percentValueRounded to (round ((percentValue * 100) * 100)) / 100 | |
set resultStr to percentValueRounded as text | |
return resultStr & "%" | |
end fmtPercent | |
--c--- get tasks count text | |
on fmtTasksCount(tasksValue) | |
set tasksValueStr to (tasksValue as integer) as text | |
return tasksValueStr | |
end fmtTasksCount | |
on run {input, parameters} | |
tell application "Things3" | |
-- # configuration | |
set inboxToDos to to dos of list "Сегодня" | |
set journalToDos to to dos of list "Журнал" | |
set taskEstimationMinutes to 30 -- # задача с одинарной сложностью кратна 30 минутам | |
set afterTaskBreakMinutes to 15 -- # перерыв для правильного подсчета времени окончания | |
set defaultMultiplierValue to 1.0 -- # множитель задачи по умолчанию | |
set N to 10 -- # нагрузочный нормальный коэффициент (N) | |
-- # end configuration | |
set totalTasksLeft to 0 | |
set totalTasksDone to 0 | |
set totalYesterdayTasksDone to 0 | |
set totalTasks to 0 | |
set todayStr to date string of (current date) | |
-- # today list | |
repeat with toDo in inboxToDos | |
set totalTasksLeft to totalTasksLeft + my getMultiplierFromToDo(toDo, defaultMultiplierValue) | |
end repeat | |
-- # today done | |
repeat with toDo in journalToDos | |
repeat 1 times -- # fake loop | |
set completionDate to completion date of toDo | |
set isCompletedToday to date string of completionDate is equal to todayStr | |
if not isCompletedToday then exit repeat | |
set totalTasksDone to totalTasksDone + my getMultiplierFromToDo(toDo, defaultMultiplierValue) | |
end repeat | |
end repeat | |
-- # yesterday done | |
repeat with toDo in journalToDos | |
repeat 1 times -- # fake loop | |
set completionDate to completion date of toDo | |
set isCompletedYesterday to date string of completionDate is equal to date string of ((current date) - 1 * days) | |
if not isCompletedYesterday then exit repeat | |
set totalYesterdayTasksDone to totalYesterdayTasksDone + my getMultiplierFromToDo(toDo, defaultMultiplierValue) | |
end repeat | |
end repeat | |
set totalTasks to totalTasksLeft + totalTasksDone | |
set totalTasksFailed to totalTasks - totalTasksDone | |
set t to (time of (current date)) | |
set estx to round ((((t + ((totalTasksFailed * (taskEstimationMinutes + afterTaskBreakMinutes)) * 60)) / 60) / 60) * 10) / 10 | |
set estxFull to (round ((((t + ((totalTasksFailed * (taskEstimationMinutes + afterTaskBreakMinutes)) * 60)) / 60) / 60) * 100)) / 100 | |
set estxMinutes to round ((estxFull - estx) * 60) | |
set workdayFinalTimeHoursStr to estx as text | |
set workdayFinalTimeMinutesStr to estxMinutes as text | |
set workdayFinalTimeStr to workdayFinalTimeHoursStr & ":" & workdayFinalTimeMinutesStr | |
set programResult to "Текущие показатели продуктивности на сегодня: | |
T = " & my fmtTasksCount(totalTasks) & " " & my fmtHrsTimeStr(totalTasks, taskEstimationMinutes) & " D = " & my fmtTasksCount(totalTasksDone) & " " & my fmtHrsTimeStr(totalTasksDone, taskEstimationMinutes) & " F = " & my fmtTasksCount(totalTasksFailed) & " " & my fmtHrsTimeStr(totalTasksFailed, taskEstimationMinutes) & " | |
Продуктивность P = " & my fmtPercent(totalTasksDone / totalTasks) & " | |
Нагрузка L = " & my fmtPercent(totalTasks / N) & " | |
Задач выполнено вчера: | |
Dy = " & my fmtTasksCount(totalYesterdayTasksDone) & " (разница " & my fmtTasksCount(totalTasksDone - totalYesterdayTasksDone) &") | |
Если текущий рабочий день не закончен, то прогноз на его окончание, с учётом количества незавершённых дел и времени на их выполнение с последующим перерывом, является " & workdayFinalTimeStr | |
display alert programResult | |
return programResult | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error "" number -1721
После обновления что-то поменялось или я делаю что-то не так?