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

feat(new tool): SLA Computer #1304

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ declare module '@vue/runtime-core' {
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSpace: typeof import('naive-ui')['NSpace']
NTable: typeof import('naive-ui')['NTable']
NStatistic: typeof import('naive-ui')['NStatistic']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
Expand All @@ -160,7 +163,7 @@ declare module '@vue/runtime-core' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SlaCalculator: typeof import('./src/tools/sla-calculator/sla-calculator.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@tiptap/pm": "2.1.6",
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/big.js": "^6.2.2",
"@types/figlet": "^1.5.8",
"@types/markdown-it": "^13.0.7",
"@vicons/material": "^0.12.0",
Expand All @@ -50,6 +51,7 @@
"@vueuse/head": "^1.0.0",
"@vueuse/router": "^10.0.0",
"bcryptjs": "^2.4.3",
"big.js": "^6.2.2",
"change-case": "^4.1.2",
"colord": "^2.9.3",
"composerize-ts": "^0.6.2",
Expand Down Expand Up @@ -81,9 +83,11 @@
"netmask": "^2.0.2",
"node-forge": "^1.3.1",
"oui-data": "^1.0.10",
"parse-duration": "^1.1.0",
"pdf-signature-reader": "^1.4.2",
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"pretty-ms": "^9.1.0",
"qrcode": "^1.5.1",
"randexp": "^0.5.3",
"sql-formatter": "^13.0.0",
Expand Down
42 changes: 39 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as slaCalculator } from './sla-calculator';
import { tool as emailNormalizer } from './email-normalizer';

import { tool as asciiTextDrawer } from './ascii-text-drawer';
Expand Down Expand Up @@ -172,7 +173,12 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Measurement',
components: [chronometer, temperatureConverter, benchmarkBuilder],
components: [
chronometer,
temperatureConverter,
benchmarkBuilder,
slaCalculator,
],
},
{
name: 'Text',
Expand Down
12 changes: 12 additions & 0 deletions src/tools/sla-calculator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Clock } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'SLA calculator',
path: '/sla-calculator',
description: 'Service Level Agreement Calcultator',
keywords: ['sla', 'service', 'level', 'agreement', 'calculator'],
component: () => import('./sla-calculator.vue'),
icon: Clock,
createdAt: new Date('2024-05-11'),
});
81 changes: 81 additions & 0 deletions src/tools/sla-calculator/sla-calculator.service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { describe, expect, it } from 'vitest';
import { downTimeToSLA, slaToDowntimes } from './sla-calculator.service';

describe('sla-calculator', () => {
describe('downTimeToSLA', () => {
it('compute correct values', () => {
expect(downTimeToSLA({
downTimeSeconds: 100,
mondayHours: 16,
tuesdayHours: 6,
wednesdayHours: 4,
thursdayHours: 24,
fridayHours: 21,
saturdayHours: 16,
sundayHours: 13,
})).to.deep.eq({
slaForDay: null,
slaForMonth: 99.99361155031703,
slaForQuarter: 99.99787051677234,
slaForWeek: 99.97222222222223,
slaForYear: 99.99946762919309,
});
expect(downTimeToSLA({
downTimeSeconds: 86400 / 10000,
})).to.deep.eq({
slaForDay: 99.99,
slaForMonth: 99.99967145115916,
slaForQuarter: 99.99989048371972,
slaForWeek: 99.99857142857142,
slaForYear: 99.99997262092992,
});
expect(downTimeToSLA({
downTimeSeconds: 86400 / 2,
})).to.deep.eq({
slaForDay: 50,
slaForMonth: 98.35725579580689,
slaForQuarter: 99.45241859860229,
slaForWeek: 92.85714285714286,
slaForYear: 99.86310464965058,
});
});
});
describe('slaToDowntimes', () => {
it('compute correct values', () => {
expect(slaToDowntimes({
targetSLA: 99,
mondayHours: 9,
tuesdayHours: 24,
wednesdayHours: 10,
thursdayHours: 8,
fridayHours: 3,
saturdayHours: 24,
sundayHours: 4,
})).to.deep.eq({
secondsPerDay: null,
secondsPerMonth: 12835.665,
secondsPerQuarter: 38506.995,
secondsPerWeek: 2952,
secondsPerYear: 154027.98,
});
expect(slaToDowntimes({
targetSLA: 99.99,
})).to.deep.eq({
secondsPerDay: 8.64,
secondsPerMonth: 262.9746,
secondsPerQuarter: 788.9238,
secondsPerWeek: 60.48,
secondsPerYear: 3155.6952,
});
expect(slaToDowntimes({
targetSLA: 99,
})).to.deep.eq({
secondsPerDay: 864,
secondsPerMonth: 26297.46,
secondsPerQuarter: 78892.38,
secondsPerWeek: 6048,
secondsPerYear: 315569.52,
});
});
});
});
Loading
Loading