Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Take working days into account when calculating average #1

Open
harmenjanssen opened this issue Jun 25, 2021 · 2 comments
Open

Take working days into account when calculating average #1

harmenjanssen opened this issue Jun 25, 2021 · 2 comments

Comments

@harmenjanssen
Copy link
Member

Problem: currently, doing a little work on a Sunday will throw off your average, whereas it should actually beef up your average.
Proposal: do not use total days to calculate the average, but only use the "official" working days. Example: working 8 hours for 4 days and doing a 1 hour job on Sunday should show an average of 8,25 hours instead of 6,6 hours.

I found that the following API contains a person's working days: https://api.productive.io/api/v2/timesheet_reports?filter%5Bafter%5D=2021-06-21&filter%5Bbefore%5D=2021-06-27&filter%5Bperson_id%5D=41757&page=1&per_page=200

Example output:

"attributes": {
    "week": "2021/W25",
    "monday_time": 579,
    "monday_capacity": 480,
    "monday_available": 450,
    "tuesday_time": 488,
    "tuesday_capacity": 480,
    "tuesday_available": 450,
    "wednesday_time": 394,
    "wednesday_capacity": 480,
    "wednesday_available": 450,
    "thursday_time": 452,
    "thursday_capacity": 480,
    "thursday_available": 450,
    "friday_time": 11,
    "friday_capacity": 0,
    "friday_available": 0,
    "saturday_time": 0,
    "saturday_capacity": 0,
    "saturday_available": 0,
    "sunday_time": 0,
    "sunday_capacity": 0,
    "sunday_available": 0
}

I think the _capacity or _available keys are significant here, although I don't understand the difference.
But either of them shows that I am not working on Friday for instance. I think we can use that to gather a person's working days from the given date and come up with the correct average.

I would work on this myself but I don't have local development figured out yet. (see other issue)

@martijngastkemper
Copy link
Member

That would be a very nice improvement. Only downside of an extra API call is time. Slash commands in Slack require a response within 3 seconds. So when adding this a limit on the amount of days could solve it. Probably 150 days (200 minus non working days), because 200 days are fetched in one API call to time_reports.

Slack offers a way to have more time, but that requires more work. Immediately send a response back and invoke another Lambda function (something like this). The payload send by Slack contains a response_url to send messages to a channel for 30 minutes: Slack docs.

@harmenjanssen
Copy link
Member Author

A limit of 200 days doesn't sound unreasonable. 🙂
Or make it a year, that's a nice period. If we move some API calls to parallel operations it might work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants