Request to accept ideas for additional features

Asked by Adam Ryczkowski on 2019-01-30

### General idea

I would like to add another feature to the program: weekly and monthly quota of the time in addition to the daily time. I would like to define the changes in such a way, that you will agree to incorporate them into your repository and eventually push them upstream. I believe there is no need for another fork of this great project. Please read the changes I propose and tell me, if you have any suggestions.

### Completely new timefile format

For that I will re-write `gettime()` so it does not re-write the timefile by the midnight, but rather keeps log of all logged time, perhaps in the form of litesql db, or in the txt format of

```
<user> <date> <total_time_in_sec>
```

sorted by the date. Old entries will get pruned or moved elsewhere.

### New UI tabs

I will also provide an option to specify weekly/monthly allowance in the glade UI.

Right now I plan to add the list that will always allow to add entries (`time limitations`) like this:

`Allow at most <amount of time> <minutes|hours> since <weekday|day of month|custom>... `

* weekday: `... <monday|tuesday|...|sunday>.`
* day of month: `...<01|02|...|31>`. If month have less than specified amount of days, it will mean the last day of month.
* custom: `...last <number> of days`.

The last option, the `custom`, seems intriguing for me, as it will not bound a kid to any artificial time boundary, like 1st of the month. Parent (me) will get the option to specify, that the kid can not play more than e.g. 2 hours per average in each window of three months.

Each entry must be satisfied in order for the kid to be able to login.

There will also be an option to grant additional time - as a reward. It will be implemented as logging negative time into the new timefile at the time of issuance.

### Modifications to the main loop in `timekpr.py`.

I would define a new function "checkTimeQuota()" which would be used instead of lines timekpr.py:279-305. It will return amount of time that is left for today.

The algorithm will be as follows:

1. Check the daily quotas as before (copy-paste lines 279-305) and get the amount of daily time left.
2. Iterate over all entris in `time limitations` and call `checkTimeLimit()` to check each one in turn. Checking the entry will yield the amount of time that is left, assuming that the account is logged in forever.
3. Return the minimum of all these numbers (and lock the account if the number is negative)

Checking the entry will be implemented like that:

`checkTimeLimit(entry, user)` will query the timefile for all the entries since `horizon_date` for the `user`.
The `horizon_date` will depend on the type of the entry. For `<weekday>` entries it will be the last `<day of the week>`, for `<day of month>` it will be last chosen day, and for `<custom>` it will be simply last `<number of days>`.

Return value would be `<amount of time> - sum(queried_timefile_entries)` after an appropriate time unit conversions.

### That's it.

Question information

Language:
English Edit question
Status:
Answered
For:
timekpr-revived Edit question
Assignee:
No assignee Edit question
Last query:
2019-01-30
Last reply:
2019-02-17
Eduards Bezverhijs (mjasnik) said : #1

I had similar ideas, but for future timekpr, which is now in beta testing phase.
Soon I'll de-support this version in favour of new timekpr, so in general I would not recomend working on this version, but if You want, it's possible, I'll merge Your patches.

Since I have a will (and skill) to do the changes I propose, perhaps you
are willing to accept my help (if the new timekeeper will still be open
source)?

If so, perhaps we can talk about it, so I know the layout of the new
project. I speak English, Polish and Russian.

Eduards Bezverhijs (mjasnik) said : #3

The new timekpr will be opensource, of course.
Currently some people are beta testing it, when I finish the GUI admin part, I'll release everything to public.
I can send You a package with new timekpr or source w/o package if You are willing to take a look.
There are config already coded in for weekly and monthly quota, albeit nothing more than that.
Shoot me an email, I'll reply.

Eduards Bezverhijs (mjasnik) said : #4

I have pushed source code to launchpad and created new project for timekpr-next.
I found some nasty bug in time accounting, so I'll rewrite some of it's code, will try to incorporate weekly and monthly quotas as well.

Eduards Bezverhijs (mjasnik) said : #5

Monthly and weekly qoutas implemented in timekpr-next.
Are You interested in checking out the new code?
Hopefully soon I'll finish graphical admin form and timekpr-next first release will happen shortly after.

On 2/17/19 6:09 PM, Eduards Bezverhijs wrote:
> Your question #678207 on timekpr-revived changed:
> https://answers.launchpad.net/timekpr-revived/+question/678207
>
> Eduards Bezverhijs posted a new comment:
> Monthly and weekly qoutas implemented in timekpr-next.
> Are You interested in checking out the new code?
> Hopefully soon I'll finish graphical admin form and timekpr-next first release will happen shortly after.
>
Yes, please. Thank you!

--

Adam Ryczkowski
+48505919892 <callto:+48505919892>

Can you help with this problem?

Provide an answer of your own, or ask Adam Ryczkowski for more information if necessary.

To post a message you must log in.