Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculation wrong? #6

Open
Calabashmc opened this issue Feb 4, 2022 · 3 comments
Open

Calculation wrong? #6

Calabashmc opened this issue Feb 4, 2022 · 3 comments

Comments

@Calabashmc
Copy link

Calabashmc commented Feb 4, 2022

I'm using this library in a small app and it is great but seems to have a small issue. Perhaps I'm doing something wrong.
I have a database with office hours.
It currenlty only has one entry which is this:
image

I have a function :

def calculate_sla_times(create_time, priority='P3'):
    office_hours = OfficeHours.query.filter_by(country_name='Australia').first()
    sla_hours = Priority.query.filter_by(priority=priority).first()
    sla_calc = SLA_Calculator()
    print(str(create_time))
    respond_calc = sla_calc.calculate(start_time=str(create_time),
                                      open_hour=office_hours.open_hour,
                                      close_hour=office_hours.close_hour,
                                      country_name=office_hours.country_name,
                                      state=office_hours.state,
                                      province=office_hours.province,
                                      sla_in_hours=sla_hours.respond_by
                                      )

    resolve_calc = sla_calc.calculate(start_time=str(create_time),
                                      open_hour=office_hours.open_hour,
                                      close_hour=office_hours.close_hour,
                                      country_name=office_hours.country_name,
                                      state=office_hours.state,
                                      province=office_hours.province,
                                      sla_in_hours=sla_hours.resolve_by
                                      )

    return respond_calc, resolve_calc

I'm in Australia and I sent in a create time which is after hours here. The sla_hours.respond_by is 1 hour. The sla_resolve_by is 2 hours.

It does skip Saturday but says adding 1 hour is like so (seem below). So Sunday rather than Monday. What am I doing wrong?

image

@imkebe
Copy link

imkebe commented Feb 6, 2022

@Calabashmc If you are interested I created new SLA Calculator and I plan to publish it in this month. It started from enhancing this library but it turned out that the way it count time is constrained in different ways, so I've created new one. My solution counts day by day and counts seconds. Everything is based on Pendulum library like it is here. Custom excluded days, different days working hours etc.

It provides describing flag for full reasoning. :)

========= 2022-01-04 10:00:50 ▶ New
We start our activity ...
🚂 SLA 1 day left
        
2022-01-04 10:03:39 👽 In the analysis
🚂 SLA 1 day left
        
2022-01-04 10:33:40 👽 To be realized
🚂 SLA 1 day left
        
2022-01-04 10:33:43 👽 In progress
🚂 SLA 1 day left
        
========= 2022-01-07 08:26:27 ⏸ For internal delivery
Active time 2 days 22 hours 25 minutes 37 seconds
Number of days to be counted 3
I count day 0, i.e. 2022-01-04 and start at 10:00:50 and end at 18:00:00 (7 hours 59 minutes 10 seconds)
I count day 1, i.e. 2022-01-05 and start from 09:00:00 and finish at 18:00:00 (9 hours)
I am counting day 2, i.e. 2022-01-06 but not, because it is a day off - Thursday 💤
I count day 3, i.e. 2022-01-07 and I start at 09:00:00 and I don't count that day because the stopping event was at 08:26:27
Start - Count Period Stop 2022-01-04 10:00:50 - 2022-01-07 08:26:27 ⏯ True
🚂 SLA remaining 7 hours 50 seconds
        
2022-01-07 08:26:54 👽 To be verified
🚂 SLA remaining 7 hours 50 seconds
        
========= 2022-02-04 22:39:18 ⏱ snapshot
✋ We are finishing up because the snapshot is in the frozen phase, or more precisely, in the pause phase

==========================================
I calculate the target point of exceeding the SLA ...
I count day 0, i.e. 2022-02-04 and start from 22:39:18 and I don't count this day because the end was at 18:00:00
I am counting day 1, i.e. 2022-02-05 but not, because it is a day off - Saturday 💤
I am counting day 2, i.e. 2022-02-06 but not, because it is a day off - Sunday 💤
I count day 3, i.e. 2022-02-07 and I start at 09:00:00 but it is less than the activity interval (until 18:00:00) so I end at 16:00:50
Delivery time until 2022-02-07 16:00:50
  • something in the log might be not fully correct (jus passed though google translator)

@Calabashmc
Copy link
Author

Hi @imkebe
Thanks. I am very interested. I look forward to using the new SLA Calculator!
Can you please let me know when it is published?

@Calabashmc
Copy link
Author

@imkebe just checking to see if your new sla-calculator is published yet?
This project seems to be dead. No new commits since 2020.

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

No branches or pull requests

2 participants