Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sifex committed Jul 24, 2022
1 parent 5029cba commit 6e2d806
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/guide/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For this example, we're working in the week of 25<sup>th</sup> - 29<sup>th</sup>
import { withBase } from 'vitepress';
</script>

<a :href="withBase('/images/sla_desc_light.svg')" class="lg:-mx-8 xl:-mx-16 my-8 lg:my-16 block">
<a :href="withBase('/images/sla_desc_light.svg')" class="lg:-mx-16 my-16 lg:my-24 xl:my-32 block">
<img :src="withBase('/images/sla_desc_dark.svg')" alt="SLA Diagram – Showing the periods of approx. 9am to 5pm covered each week day " class="w-full hidden dark:block">
<img :src="withBase('/images/sla_desc_light.svg')" alt="SLA Diagram – Showing the periods of approx. 9am to 5pm covered each week day " class="w-full dark:hidden">
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/pausing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { withBase } from 'vitepress';
Pausing works retroactively to the `status` or `duration` method and is required to be defined before we calculate the full SLA.


<a :href="withBase('/images/sla_pause_light.svg')" class="lg:-mx-8 xl:-mx-16 my-8 lg:my-16 block !mb-0">
<a :href="withBase('/images/sla_pause_light.svg')" class="lg:-mx-16 my-16 lg:my-24 xl:my-32 block !mb-0">
<img :src="withBase('/images/sla_pause_dark.svg')" alt="SLA Pausing Diagram – Showing the periods of approx. 9am to 5pm covered each week day, but with a paused period on Wednesday" class="w-full hidden dark:block !mt-0">
<img :src="withBase('/images/sla_pause_light.svg')" alt="SLA Pausing Diagram – Showing the periods of approx. 9am to 5pm covered each week day, but with a paused period on Wednesday" class="w-full dark:hidden">
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/SLA.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private function calculate($subject_start_time, $subject_stop_time = null): SLAS
$sla_periods = $this->recalculate_sla_periods($main_target_period->start, $main_target_period->end);

// Iterate over the period
$interval = collect($main_target_period)->map(function (Carbon $daily_subject_period) use ($main_target_period, $sla_periods) {
$interval = collect($main_target_period)->map(function (Carbon $daily_subject_period) use ($main_target_period, &$sla_periods) {
/**
* After we've divided each day, find where the start and end times are by min/max'ing them
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/SLATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@

testTime()->freeze('2022-07-27 10:00:00'); // After Period on the 27th
expect($sla->duration('2022-07-25 08:59:00')->totalSeconds)->toEqual(150);

testTime()->freeze('2022-07-28 10:00:00'); // After Period on the 28th
expect($sla->duration('2022-07-25 08:59:00')->totalSeconds)->toEqual(180);

testTime()->freeze('2022-07-29 10:00:00'); // After Period on the 29th
expect($sla->duration('2022-07-25 08:59:00')->totalSeconds)->toEqual(210);

testTime()->freeze('2022-07-30 10:00:00'); // After Period on the 30th
expect($sla->duration('2022-07-25 08:59:00')->totalSeconds)->toEqual(220);

testTime()->freeze('2022-07-31 10:00:00'); // After Period on the 31st
expect($sla->duration('2022-07-25 08:59:00')->totalSeconds)->toEqual(230);
});

//it('tests 0 length SLAs', function () {
Expand Down

0 comments on commit 6e2d806

Please sign in to comment.