2021-06-24 19:22:12 +02:00
|
|
|
import { IYesNoCount } from './models';
|
2016-11-04 16:16:55 +01:00
|
|
|
|
2021-06-24 19:22:12 +02:00
|
|
|
export class Projection {
|
|
|
|
store: Record<string, IYesNoCount> = {};
|
2016-11-04 16:16:55 +01:00
|
|
|
|
2021-06-24 19:22:12 +02:00
|
|
|
getProjection(): Record<string, IYesNoCount> {
|
2016-11-04 16:16:55 +01:00
|
|
|
return this.store;
|
|
|
|
}
|
|
|
|
|
2021-06-24 19:22:12 +02:00
|
|
|
add(name: string, countObj: IYesNoCount): void {
|
2016-11-04 16:16:55 +01:00
|
|
|
if (this.store[name]) {
|
|
|
|
this.store[name].yes += countObj.yes;
|
|
|
|
this.store[name].no += countObj.no;
|
|
|
|
} else {
|
|
|
|
this.store[name] = {
|
|
|
|
yes: countObj.yes,
|
|
|
|
no: countObj.no,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-24 19:22:12 +02:00
|
|
|
substract(name: string, countObj: IYesNoCount): void {
|
2016-11-04 16:16:55 +01:00
|
|
|
if (this.store[name]) {
|
|
|
|
this.store[name].yes -= countObj.yes;
|
|
|
|
this.store[name].no -= countObj.no;
|
|
|
|
} else {
|
|
|
|
this.store[name] = {
|
|
|
|
yes: 0,
|
|
|
|
no: 0,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 19:22:12 +02:00
|
|
|
}
|