diff --git a/Common/Types/Decimal.ts b/Common/Types/Decimal.ts index 4082af902d..bde53e55de 100644 --- a/Common/Types/Decimal.ts +++ b/Common/Types/Decimal.ts @@ -5,7 +5,6 @@ import { JSONObject, ObjectType } from './JSON'; import BadDataException from './Exception/BadDataException'; export default class Decimal extends DatabaseProperty { - private _value: number = 0; public get value(): number { return this._value; @@ -36,7 +35,6 @@ export default class Decimal extends DatabaseProperty { return this.value.toString(); } - protected static override toDatabase( value: Decimal | FindOperator ): string | null { @@ -70,7 +68,6 @@ export default class Decimal extends DatabaseProperty { return null; } - public static fromString(value: string): Decimal { return new Decimal(value); } diff --git a/CommonServer/Services/UsageBillingService.ts b/CommonServer/Services/UsageBillingService.ts index 70e8044ced..c726d038c2 100644 --- a/CommonServer/Services/UsageBillingService.ts +++ b/CommonServer/Services/UsageBillingService.ts @@ -94,11 +94,13 @@ export class Service extends DatabaseService { await this.updateOneById({ id: usageBilling.id, data: { - usageCount: - new Decimal((usageBilling.usageCount?.value || 0) + data.usageCount), - totalCostInUSD:new Decimal( + usageCount: new Decimal( + (usageBilling.usageCount?.value || 0) + data.usageCount + ), + totalCostInUSD: new Decimal( (usageBilling.totalCostInUSD?.value || 0) + - totalCostOfThisOperationInUSD), + totalCostOfThisOperationInUSD + ), }, props: { isRoot: true, @@ -114,7 +116,9 @@ export class Service extends DatabaseService { usageBilling.day = OneUptimeDate.getDateString( OneUptimeDate.getCurrentDate() ); - usageBilling.totalCostInUSD = new Decimal(totalCostOfThisOperationInUSD); + usageBilling.totalCostInUSD = new Decimal( + totalCostOfThisOperationInUSD + ); usageBilling.usageUnitName = meteredPlan.getUnitName(); // e.g. "GB" await this.create({ diff --git a/Dashboard/src/Pages/Settings/UsageHistory.tsx b/Dashboard/src/Pages/Settings/UsageHistory.tsx index 545986fdf0..ba7950b225 100644 --- a/Dashboard/src/Pages/Settings/UsageHistory.tsx +++ b/Dashboard/src/Pages/Settings/UsageHistory.tsx @@ -94,7 +94,8 @@ const Settings: FunctionComponent = ( getElement: (item: JSONObject) => { return (
{`${DiskSize.convertToDecimalPlaces( - (item['usageCount'] as Decimal).value as number + (item['usageCount'] as Decimal) + .value as number )} ${item['usageUnitName'] as string}`}
); }, @@ -108,7 +109,8 @@ const Settings: FunctionComponent = ( getElement: (item: JSONObject) => { return (
{`${Currency.convertToDecimalPlaces( - (item['totalCostInUSD'] as Decimal).value as number + (item['totalCostInUSD'] as Decimal) + .value as number )} USD`}
); }, diff --git a/HelmChart/Tests/index.sh b/HelmChart/Tests/index.sh index 7f2eb21b2d..df4d5487d3 100644 --- a/HelmChart/Tests/index.sh +++ b/HelmChart/Tests/index.sh @@ -1,26 +1,26 @@ # Install MicroK8s -snap install microk8s --classic -microk8s status --wait-ready +sudo snap install microk8s --classic +sudo microk8s status --wait-ready # Add current user to microk8s group -microk8s kubectl config view --raw > ~/.kube/config +sudo microk8s kubectl config view --raw > ~/.kube/config # Add kubectl and helm aliases -echo "alias kubectl='microk8s kubectl'" >> ~/.bash_aliases -echo "alias helm='microk8s helm3'" >> ~/.bash_aliases +sudo echo "alias kubectl='microk8s kubectl'" >> ~/.bash_aliases +sudo echo "alias helm='microk8s helm3'" >> ~/.bash_aliases # Enable MicroK8s addons -microk8s enable dashboard -microk8s enable dns -microk8s enable hostpath-storage +sudo microk8s enable dashboard +sudo microk8s enable dns +sudo microk8s enable hostpath-storage # Install OneUptime -helm install oneuptime ../../HelmChart/Public/oneuptime -f ../../HelmChart/Public/oneuptime/values.yaml -f ./ci-values.yaml +sudo helm install oneuptime ../../HelmChart/Public/oneuptime -f ../../HelmChart/Public/oneuptime/values.yaml -f ./ci-values.yaml # Wait for OneUptime to be ready -kubectl wait --for=condition=ready pod -l --timeout=300s +sudo kubectl wait --for=condition=ready pod -l --timeout=300s # Once it's ready. Run helm test. -helm test oneuptime +sudo helm test oneuptime diff --git a/Ingestor/API/OTelIngest.ts b/Ingestor/API/OTelIngest.ts index 6a6ae1a8d8..a5a0942ef4 100644 --- a/Ingestor/API/OTelIngest.ts +++ b/Ingestor/API/OTelIngest.ts @@ -65,7 +65,6 @@ router.use( '/otel/*', async (req: ExpressRequest, _res: ExpressResponse, next: NextFunction) => { try { - // check header. const serviceTokenInHeader: string | undefined = req.headers[ @@ -100,8 +99,6 @@ router.use( throw new BadRequestException('Invalid URL: ' + req.baseUrl); } - - const cachedServiceId: string | null = await GlobalCache.getString( 'service-token', serviceTokenInHeader as string @@ -281,7 +278,7 @@ router.post( (metric['sum'] as JSONObject)['dataPoints'] && ( (metric['sum'] as JSONObject)[ - 'dataPoints' + 'dataPoints' ] as JSONArray ).length > 0 ) { @@ -331,7 +328,7 @@ router.post( (metric['gauge'] as JSONObject)['dataPoints'] && ( (metric['gauge'] as JSONObject)[ - 'dataPoints' + 'dataPoints' ] as JSONArray ).length > 0 ) { @@ -382,7 +379,7 @@ router.post( (metric['histogram'] as JSONObject)['dataPoints'] && ( (metric['histogram'] as JSONObject)[ - 'dataPoints' + 'dataPoints' ] as JSONArray ).length > 0 ) { diff --git a/Model/Models/UsageBilling.ts b/Model/Models/UsageBilling.ts index 4e04d4c133..bd15575b2b 100644 --- a/Model/Models/UsageBilling.ts +++ b/Model/Models/UsageBilling.ts @@ -171,7 +171,7 @@ export default class UsageBilling extends AccessControlModel { @Column({ nullable: false, type: ColumnType.Decimal, - transformer: Decimal.getDatabaseTransformer() + transformer: Decimal.getDatabaseTransformer(), }) public usageCount?: Decimal = undefined; @@ -218,7 +218,7 @@ export default class UsageBilling extends AccessControlModel { @Column({ nullable: false, type: ColumnType.Decimal, - transformer: Decimal.getDatabaseTransformer() + transformer: Decimal.getDatabaseTransformer(), }) public totalCostInUSD?: Decimal = undefined;