mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Fix bug in login functionality
This commit is contained in:
parent
8d35f5eb2d
commit
f5803d34ff
@ -5,7 +5,6 @@ import { JSONObject, ObjectType } from './JSON';
|
|||||||
import BadDataException from './Exception/BadDataException';
|
import BadDataException from './Exception/BadDataException';
|
||||||
|
|
||||||
export default class Decimal extends DatabaseProperty {
|
export default class Decimal extends DatabaseProperty {
|
||||||
|
|
||||||
private _value: number = 0;
|
private _value: number = 0;
|
||||||
public get value(): number {
|
public get value(): number {
|
||||||
return this._value;
|
return this._value;
|
||||||
@ -36,7 +35,6 @@ export default class Decimal extends DatabaseProperty {
|
|||||||
return this.value.toString();
|
return this.value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static override toDatabase(
|
protected static override toDatabase(
|
||||||
value: Decimal | FindOperator<Decimal>
|
value: Decimal | FindOperator<Decimal>
|
||||||
): string | null {
|
): string | null {
|
||||||
@ -70,7 +68,6 @@ export default class Decimal extends DatabaseProperty {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static fromString(value: string): Decimal {
|
public static fromString(value: string): Decimal {
|
||||||
return new Decimal(value);
|
return new Decimal(value);
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,13 @@ export class Service extends DatabaseService<Model> {
|
|||||||
await this.updateOneById({
|
await this.updateOneById({
|
||||||
id: usageBilling.id,
|
id: usageBilling.id,
|
||||||
data: {
|
data: {
|
||||||
usageCount:
|
usageCount: new Decimal(
|
||||||
new Decimal((usageBilling.usageCount?.value || 0) + data.usageCount),
|
(usageBilling.usageCount?.value || 0) + data.usageCount
|
||||||
totalCostInUSD:new Decimal(
|
),
|
||||||
|
totalCostInUSD: new Decimal(
|
||||||
(usageBilling.totalCostInUSD?.value || 0) +
|
(usageBilling.totalCostInUSD?.value || 0) +
|
||||||
totalCostOfThisOperationInUSD),
|
totalCostOfThisOperationInUSD
|
||||||
|
),
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
isRoot: true,
|
isRoot: true,
|
||||||
@ -114,7 +116,9 @@ export class Service extends DatabaseService<Model> {
|
|||||||
usageBilling.day = OneUptimeDate.getDateString(
|
usageBilling.day = OneUptimeDate.getDateString(
|
||||||
OneUptimeDate.getCurrentDate()
|
OneUptimeDate.getCurrentDate()
|
||||||
);
|
);
|
||||||
usageBilling.totalCostInUSD = new Decimal(totalCostOfThisOperationInUSD);
|
usageBilling.totalCostInUSD = new Decimal(
|
||||||
|
totalCostOfThisOperationInUSD
|
||||||
|
);
|
||||||
usageBilling.usageUnitName = meteredPlan.getUnitName(); // e.g. "GB"
|
usageBilling.usageUnitName = meteredPlan.getUnitName(); // e.g. "GB"
|
||||||
|
|
||||||
await this.create({
|
await this.create({
|
||||||
|
@ -94,7 +94,8 @@ const Settings: FunctionComponent<ComponentProps> = (
|
|||||||
getElement: (item: JSONObject) => {
|
getElement: (item: JSONObject) => {
|
||||||
return (
|
return (
|
||||||
<div>{`${DiskSize.convertToDecimalPlaces(
|
<div>{`${DiskSize.convertToDecimalPlaces(
|
||||||
(item['usageCount'] as Decimal).value as number
|
(item['usageCount'] as Decimal)
|
||||||
|
.value as number
|
||||||
)} ${item['usageUnitName'] as string}`}</div>
|
)} ${item['usageUnitName'] as string}`}</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -108,7 +109,8 @@ const Settings: FunctionComponent<ComponentProps> = (
|
|||||||
getElement: (item: JSONObject) => {
|
getElement: (item: JSONObject) => {
|
||||||
return (
|
return (
|
||||||
<div>{`${Currency.convertToDecimalPlaces(
|
<div>{`${Currency.convertToDecimalPlaces(
|
||||||
(item['totalCostInUSD'] as Decimal).value as number
|
(item['totalCostInUSD'] as Decimal)
|
||||||
|
.value as number
|
||||||
)} USD`}</div>
|
)} USD`}</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
# Install MicroK8s
|
# Install MicroK8s
|
||||||
snap install microk8s --classic
|
sudo snap install microk8s --classic
|
||||||
microk8s status --wait-ready
|
sudo microk8s status --wait-ready
|
||||||
|
|
||||||
|
|
||||||
# Add current user to microk8s group
|
# 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
|
# Add kubectl and helm aliases
|
||||||
echo "alias kubectl='microk8s kubectl'" >> ~/.bash_aliases
|
sudo echo "alias kubectl='microk8s kubectl'" >> ~/.bash_aliases
|
||||||
echo "alias helm='microk8s helm3'" >> ~/.bash_aliases
|
sudo echo "alias helm='microk8s helm3'" >> ~/.bash_aliases
|
||||||
|
|
||||||
# Enable MicroK8s addons
|
# Enable MicroK8s addons
|
||||||
microk8s enable dashboard
|
sudo microk8s enable dashboard
|
||||||
microk8s enable dns
|
sudo microk8s enable dns
|
||||||
microk8s enable hostpath-storage
|
sudo microk8s enable hostpath-storage
|
||||||
|
|
||||||
|
|
||||||
# Install OneUptime
|
# 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
|
# 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.
|
# Once it's ready. Run helm test.
|
||||||
helm test oneuptime
|
sudo helm test oneuptime
|
||||||
|
@ -65,7 +65,6 @@ router.use(
|
|||||||
'/otel/*',
|
'/otel/*',
|
||||||
async (req: ExpressRequest, _res: ExpressResponse, next: NextFunction) => {
|
async (req: ExpressRequest, _res: ExpressResponse, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// check header.
|
// check header.
|
||||||
|
|
||||||
const serviceTokenInHeader: string | undefined = req.headers[
|
const serviceTokenInHeader: string | undefined = req.headers[
|
||||||
@ -100,8 +99,6 @@ router.use(
|
|||||||
throw new BadRequestException('Invalid URL: ' + req.baseUrl);
|
throw new BadRequestException('Invalid URL: ' + req.baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const cachedServiceId: string | null = await GlobalCache.getString(
|
const cachedServiceId: string | null = await GlobalCache.getString(
|
||||||
'service-token',
|
'service-token',
|
||||||
serviceTokenInHeader as string
|
serviceTokenInHeader as string
|
||||||
@ -281,7 +278,7 @@ router.post(
|
|||||||
(metric['sum'] as JSONObject)['dataPoints'] &&
|
(metric['sum'] as JSONObject)['dataPoints'] &&
|
||||||
(
|
(
|
||||||
(metric['sum'] as JSONObject)[
|
(metric['sum'] as JSONObject)[
|
||||||
'dataPoints'
|
'dataPoints'
|
||||||
] as JSONArray
|
] as JSONArray
|
||||||
).length > 0
|
).length > 0
|
||||||
) {
|
) {
|
||||||
@ -331,7 +328,7 @@ router.post(
|
|||||||
(metric['gauge'] as JSONObject)['dataPoints'] &&
|
(metric['gauge'] as JSONObject)['dataPoints'] &&
|
||||||
(
|
(
|
||||||
(metric['gauge'] as JSONObject)[
|
(metric['gauge'] as JSONObject)[
|
||||||
'dataPoints'
|
'dataPoints'
|
||||||
] as JSONArray
|
] as JSONArray
|
||||||
).length > 0
|
).length > 0
|
||||||
) {
|
) {
|
||||||
@ -382,7 +379,7 @@ router.post(
|
|||||||
(metric['histogram'] as JSONObject)['dataPoints'] &&
|
(metric['histogram'] as JSONObject)['dataPoints'] &&
|
||||||
(
|
(
|
||||||
(metric['histogram'] as JSONObject)[
|
(metric['histogram'] as JSONObject)[
|
||||||
'dataPoints'
|
'dataPoints'
|
||||||
] as JSONArray
|
] as JSONArray
|
||||||
).length > 0
|
).length > 0
|
||||||
) {
|
) {
|
||||||
|
@ -171,7 +171,7 @@ export default class UsageBilling extends AccessControlModel {
|
|||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
type: ColumnType.Decimal,
|
type: ColumnType.Decimal,
|
||||||
transformer: Decimal.getDatabaseTransformer()
|
transformer: Decimal.getDatabaseTransformer(),
|
||||||
})
|
})
|
||||||
public usageCount?: Decimal = undefined;
|
public usageCount?: Decimal = undefined;
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ export default class UsageBilling extends AccessControlModel {
|
|||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
type: ColumnType.Decimal,
|
type: ColumnType.Decimal,
|
||||||
transformer: Decimal.getDatabaseTransformer()
|
transformer: Decimal.getDatabaseTransformer(),
|
||||||
})
|
})
|
||||||
public totalCostInUSD?: Decimal = undefined;
|
public totalCostInUSD?: Decimal = undefined;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user