修复定时任务/视图/环境变量更新逻辑

This commit is contained in:
whyour
2023-02-24 23:21:08 +08:00
parent 697bcb5922
commit e1e6261b4f
3 changed files with 12 additions and 8 deletions
+7 -3
View File
@@ -16,7 +16,7 @@ import { Op } from 'sequelize';
@Service()
export default class EnvService {
constructor(@Inject('logger') private logger: winston.Logger) { }
constructor(@Inject('logger') private logger: winston.Logger) {}
public async create(payloads: Env[]): Promise<Env[]> {
const envs = await this.envs();
@@ -49,7 +49,7 @@ export default class EnvService {
}
public async update(payload: Env): Promise<Env> {
const newDoc = await this.updateDb(payload);
const newDoc = await this.updateDb(new Env(payload));
await this.set_envs();
return newDoc;
}
@@ -98,7 +98,11 @@ export default class EnvService {
private async checkPosition(position: number, edge: number = 0) {
const precisionPosition = parseFloat(position.toPrecision(16));
if (precisionPosition < minPosition || precisionPosition > maxPosition || Math.abs(precisionPosition - edge) < minPosition) {
if (
precisionPosition < minPosition ||
precisionPosition > maxPosition ||
Math.abs(precisionPosition - edge) < minPosition
) {
const envs = await this.envs();
let position = initPosition;
for (const env of envs) {