Skip to content

Commit

Permalink
Merge pull request #63 from ScottLogic/user-employee-rename
Browse files Browse the repository at this point in the history
Change 'User' to 'Employee'
  • Loading branch information
sdun-scottlogic authored May 31, 2024
2 parents 0a55178 + f460a40 commit 96763a0
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ This contains the data as entered on the main form, which uses Angular FormGroup
classDiagram
class DeviceCategory {
<<union>>
'user'
'employee'
'server'
'network'
}
Expand All @@ -125,7 +125,7 @@ classDiagram
class UpstreamEstimation {
software: number
user: number
employee: number
network: number
server: number
}
Expand All @@ -135,7 +135,7 @@ classDiagram
managed: number
}
class DirectEstimation {
user: number
employee: number
network: number
server: number
}
Expand Down
24 changes: 12 additions & 12 deletions src/app/carbon-estimation/carbon-estimation.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('CarbonEstimationComponent', () => {
version: '1.0',
upstreamEmissions: {
software: 7,
user: 6,
employee: 6,
network: 6,
server: 6,
},
directEmissions: {
user: 9,
employee: 9,
network: 8,
server: 8,
},
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('CarbonEstimationComponent', () => {
meta: { svg: 'web-logo', parent: 'Upstream Emissions' },
},
{
x: 'User Hardware',
x: 'Employee Hardware',
y: 6,
meta: { svg: 'devices-logo', parent: 'Upstream Emissions' },
},
Expand All @@ -139,7 +139,7 @@ describe('CarbonEstimationComponent', () => {
color: '#CB3775',
data: [
{
x: 'User Devices',
x: 'Employee Devices',
y: 9,
meta: { svg: 'devices-logo', parent: 'Direct Emissions' },
},
Expand Down Expand Up @@ -206,12 +206,12 @@ describe('CarbonEstimationComponent', () => {
version: '1.0',
upstreamEmissions: {
software: 0.2,
user: 0.1,
employee: 0.1,
network: 0.1,
server: 0.1,
},
directEmissions: {
user: 34.5,
employee: 34.5,
network: 8,
server: 8,
},
Expand All @@ -237,12 +237,12 @@ describe('CarbonEstimationComponent', () => {
version: '1.0',
upstreamEmissions: {
software: 25,
user: 0,
employee: 0,
network: 0,
server: 0,
},
directEmissions: {
user: 25,
employee: 25,
network: 0,
server: 0,
},
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('CarbonEstimationComponent', () => {
color: '#CB3775',
data: [
{
x: 'User Devices',
x: 'Employee Devices',
y: 25,
meta: { svg: 'devices-logo', parent: 'Direct Emissions' },
},
Expand Down Expand Up @@ -315,12 +315,12 @@ describe('CarbonEstimationComponent', () => {
version: '1.0',
upstreamEmissions: {
software: 50,
user: 0,
employee: 0,
network: 0,
server: 0,
},
directEmissions: {
user: 50,
employee: 50,
network: 0,
server: 0,
},
Expand Down Expand Up @@ -355,7 +355,7 @@ describe('CarbonEstimationComponent', () => {
color: '#CB3775',
data: [
{
x: 'User Devices',
x: 'Employee Devices',
y: 50,
meta: { svg: 'devices-logo', parent: 'Direct Emissions' },
},
Expand Down
10 changes: 5 additions & 5 deletions src/app/carbon-estimation/carbon-estimation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class CarbonEstimationComponent implements OnInit {
return this.getDataItemObject('Software - Off the Shelf', value, SVG.WEB, parent);
case 'saas':
return this.getDataItemObject('SaaS', value, SVG.WEB, parent);
case 'user':
return this.getDataItemObject(this.getUserLabel(parent), value, SVG.DEVICES, parent);
case 'employee':
return this.getDataItemObject(this.getEmployeeLabel(parent), value, SVG.DEVICES, parent);
case 'endUser':
return this.getDataItemObject('End-User Devices', value, SVG.DEVICES, parent);
case 'network':
Expand Down Expand Up @@ -183,12 +183,12 @@ export class CarbonEstimationComponent implements OnInit {
};
}

private getUserLabel(key: string): string {
private getEmployeeLabel(key: string): string {
switch (key) {
case 'Upstream Emissions':
return 'User Hardware';
return 'Employee Hardware';
case 'Direct Emissions':
return 'User Devices';
return 'Employee Devices';
default:
return startCase(key);
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/estimation/device-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { estimateEnergyEmissions } from './estimate-energy-emissions';

describe('createDeviceUsage()', () => {
it('should expose device category', () => {
expect(createDeviceUsage(laptop, 'user', 0, 0).category).toBe('user');
expect(createDeviceUsage(laptop, 'employee', 0, 0).category).toBe('employee');
expect(createDeviceUsage(laptop, 'server', 0, 0).category).toBe('server');
expect(createDeviceUsage(laptop, 'network', 0, 0).category).toBe('network');
});

it('should estimate upstream emissions using device type', () => {
spyOn(laptop, 'estimateYearlyUpstreamEmissions').and.callFake(() => 42);
const deviceCount = 10;
const usage = createDeviceUsage(laptop, 'user', 0, deviceCount);
const usage = createDeviceUsage(laptop, 'employee', 0, deviceCount);

expect(usage.estimateUpstreamEmissions()).toBe(42);
expect(laptop.estimateYearlyUpstreamEmissions).toHaveBeenCalledOnceWith(deviceCount);
Expand All @@ -22,7 +22,7 @@ describe('createDeviceUsage()', () => {
spyOn(laptop, 'estimateYearlyEnergy').and.callFake(() => 42);
const deviceCount = 100;
const carbonIntensity = 500;
const usage = createDeviceUsage(laptop, 'user', carbonIntensity, deviceCount);
const usage = createDeviceUsage(laptop, 'employee', carbonIntensity, deviceCount);

const expectedEmissions = estimateEnergyEmissions(42, carbonIntensity);
expect(usage.estimateDirectEmissions()).toBe(expectedEmissions);
Expand All @@ -34,7 +34,7 @@ describe('createDeviceUsage()', () => {
const deviceCount = 1000;
const carbonIntensity = 500;
const pue = 2;
const usage = createDeviceUsage(laptop, 'user', carbonIntensity, deviceCount, pue);
const usage = createDeviceUsage(laptop, 'employee', carbonIntensity, deviceCount, pue);

const expectedEmissions = estimateEnergyEmissions(84, carbonIntensity);
expect(usage.estimateDirectEmissions()).toBe(expectedEmissions);
Expand Down
14 changes: 7 additions & 7 deletions src/app/estimation/estimate-direct-emissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ describe('estimateDirectEmissions', () => {

it('should return no emissions for an empty list', () => {
expect(estimateDirectEmissions([])).toEqual({
user: 0,
employee: 0,
server: 0,
network: 0,
});
});

it('should allocate emissions to relevant category', () => {
const deviceUsage: DeviceUsage[] = [
createDirectDeviceUsageStub('user', 1),
createDirectDeviceUsageStub('employee', 1),
createDirectDeviceUsageStub('server', 2),
createDirectDeviceUsageStub('network', 3),
];

expect(estimateDirectEmissions(deviceUsage)).toEqual({
user: 1,
employee: 1,
server: 2,
network: 3,
});
});

it('should total multiple emissions in the same category', () => {
const deviceUsage: DeviceUsage[] = [
createDirectDeviceUsageStub('user', 1),
createDirectDeviceUsageStub('user', 2),
createDirectDeviceUsageStub('user', 3),
createDirectDeviceUsageStub('employee', 1),
createDirectDeviceUsageStub('employee', 2),
createDirectDeviceUsageStub('employee', 3),
];
expect(estimateDirectEmissions(deviceUsage)).toEqual({
user: 6,
employee: 6,
server: 0,
network: 0,
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/estimation/estimate-direct-emissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeviceUsage } from './device-usage';

export function estimateDirectEmissions(deviceUsage: DeviceUsage[]): DirectEstimation {
const result: Record<DeviceCategory, number> = {
user: 0,
employee: 0,
server: 0,
network: 0,
};
Expand Down
14 changes: 7 additions & 7 deletions src/app/estimation/estimate-upstream-emissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ describe('estimateUpstreamEmissions', () => {
it('should return no emissions for an empty list', () => {
expect(estimateUpstreamEmissions([])).toEqual({
software: 0,
user: 0,
employee: 0,
server: 0,
network: 0,
});
});

it('should allocate emissions to relevant category', () => {
const deviceUsage: DeviceUsage[] = [
createUpstreamDeviceUsageStub('user', 1),
createUpstreamDeviceUsageStub('employee', 1),
createUpstreamDeviceUsageStub('server', 2),
createUpstreamDeviceUsageStub('network', 3),
];

expect(estimateUpstreamEmissions(deviceUsage)).toEqual({
software: 0,
user: 1,
employee: 1,
server: 2,
network: 3,
});
});

it('should total multiple emissions in the same category', () => {
const deviceUsage: DeviceUsage[] = [
createUpstreamDeviceUsageStub('user', 1),
createUpstreamDeviceUsageStub('user', 2),
createUpstreamDeviceUsageStub('user', 3),
createUpstreamDeviceUsageStub('employee', 1),
createUpstreamDeviceUsageStub('employee', 2),
createUpstreamDeviceUsageStub('employee', 3),
];
expect(estimateUpstreamEmissions(deviceUsage)).toEqual({
software: 0,
user: 6,
employee: 6,
server: 0,
network: 0,
});
Expand Down
2 changes: 1 addition & 1 deletion src/app/estimation/estimate-upstream-emissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeviceUsage } from './device-usage';

export function estimateUpstreamEmissions(deviceUsage: DeviceUsage[]): UpstreamEstimation {
const result: Record<DeviceCategory, number> = {
user: 0,
employee: 0,
server: 0,
network: 0,
};
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/carbon-estimation.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ describe('CarbonEstimationService', () => {
const result = service.calculateCarbonEstimation(hardwareInput);
expectPartialEstimationCloseTo(result, {
upstreamEmissions: {
user: 5.78,
employee: 5.78,
server: 7.64,
network: 3.43,
},
directEmissions: {
user: 2.89,
employee: 2.89,
server: 58.37,
network: 21.89,
},
Expand All @@ -217,12 +217,12 @@ describe('CarbonEstimationService', () => {
const result = service.calculateCarbonEstimation(hardwareInput);
expectPartialEstimationCloseTo(result, {
upstreamEmissions: {
user: 6.21,
employee: 6.21,
server: 8.21,
network: 3.68,
},
directEmissions: {
user: 1.55,
employee: 1.55,
server: 62.71,
network: 17.64,
},
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/carbon-estimation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ export class CarbonEstimationService {
const employeeIntensity = this.carbonIntensityService.getCarbonIntensity(formValue.upstream.employeeLocation);
const onPremIntensity = this.carbonIntensityService.getCarbonIntensity(formValue.onPremise.serverLocation);
return [
createDeviceUsage(desktop, 'user', employeeIntensity, desktopCount),
createDeviceUsage(laptop, 'user', employeeIntensity, laptopCount),
createDeviceUsage(desktop, 'employee', employeeIntensity, desktopCount),
createDeviceUsage(laptop, 'employee', employeeIntensity, laptopCount),
createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(server, 'server', onPremIntensity, serverCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(network, 'network', onPremIntensity, serverNetworkCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(monitor, 'user', employeeIntensity, monitorCount),
createDeviceUsage(monitor, 'employee', employeeIntensity, monitorCount),
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('TechCarbonEstimatorComponent', () => {
version: '0.0.0',
upstreamEmissions: {
software: 0,
user: 10,
employee: 10,
network: 10,
server: 5,
},
Expand All @@ -25,7 +25,7 @@ describe('TechCarbonEstimatorComponent', () => {
cloud: 25,
},
directEmissions: {
user: 10,
employee: 10,
network: 10,
server: 5,
},
Expand Down
6 changes: 3 additions & 3 deletions src/app/types/carbon-estimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type CarbonEstimation = {

export type UpstreamEstimation = {
software: number;
user: number;
employee: number;
network: number;
server: number;
};
Expand All @@ -21,7 +21,7 @@ export type IndirectEstimation = {
managed: number;
};
export type DirectEstimation = {
user: number;
employee: number;
network: number;
server: number;
};
Expand Down Expand Up @@ -87,7 +87,7 @@ export type Downstream = {
purposeOfSite: PurposeOfSite;
};

export type DeviceCategory = 'user' | 'server' | 'network';
export type DeviceCategory = 'employee' | 'server' | 'network';

export const locationArray = [
'WORLD',
Expand Down

0 comments on commit 96763a0

Please sign in to comment.