Compare commits
No commits in common. "production" and "1.4.5-production.1" have entirely different histories.
production
...
1.4.5-prod
|
@ -19,7 +19,6 @@ export class CouchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
// return;
|
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
for (const database of DatabaseListen) {
|
for (const database of DatabaseListen) {
|
||||||
const db = nano.db.use(database);
|
const db = nano.db.use(database);
|
||||||
|
@ -96,41 +95,4 @@ export class CouchService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnixTimestampLast7Days() {
|
|
||||||
const date = new Date();
|
|
||||||
date.setDate(date.getDate() - 4);
|
|
||||||
date.setHours(0, 0, 0, 0);
|
|
||||||
return date.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async clearTransactions() {
|
|
||||||
const nano = this.nanoInstance;
|
|
||||||
const transaction = nano.use('transaction');
|
|
||||||
|
|
||||||
const expiredDate = this.getUnixTimestampLast7Days();
|
|
||||||
|
|
||||||
const selectorPayment = {
|
|
||||||
created_at: {
|
|
||||||
$lt: expiredDate,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const transactions = await transaction.find({
|
|
||||||
selector: selectorPayment,
|
|
||||||
fields: ['_id', '_rev'],
|
|
||||||
limit: 100000,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { docs } = transactions;
|
|
||||||
console.log(docs.length);
|
|
||||||
const deletedDocs = {
|
|
||||||
docs: docs.map((doc) => ({
|
|
||||||
_id: doc._id,
|
|
||||||
_rev: doc._rev,
|
|
||||||
_deleted: true,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
await transaction.bulk(deletedDocs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,13 @@ import { Public } from 'src/core/guards';
|
||||||
import * as Nano from 'nano';
|
import * as Nano from 'nano';
|
||||||
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { CouchService } from '../data/services/couch.service';
|
|
||||||
|
|
||||||
@ApiTags(`couch`)
|
@ApiTags(`couch`)
|
||||||
@Controller('v1/couch')
|
@Controller('v1/couch')
|
||||||
@Public()
|
@Public()
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CouchDataController {
|
export class CouchDataController {
|
||||||
constructor(
|
constructor(private configService: ConfigService) {}
|
||||||
private configService: ConfigService,
|
|
||||||
private couchService: CouchService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
get nanoInstance() {
|
get nanoInstance() {
|
||||||
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
||||||
|
@ -68,11 +64,4 @@ export class CouchDataController {
|
||||||
// return people.get();
|
// return people.get();
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public(true)
|
|
||||||
@Get('clear-transactions')
|
|
||||||
async clearTransactions(): Promise<string> {
|
|
||||||
await this.couchService.clearTransactions();
|
|
||||||
return 'OK';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ export class GenerateQueueManager {
|
||||||
qty: data.qty,
|
qty: data.qty,
|
||||||
item_id: queue.id,
|
item_id: queue.id,
|
||||||
vip: isVip,
|
vip: isVip,
|
||||||
|
showTime: false,
|
||||||
};
|
};
|
||||||
const registerQueueManager = new RegisterQueueManager(
|
const registerQueueManager = new RegisterQueueManager(
|
||||||
this.bucketService,
|
this.bucketService,
|
||||||
|
@ -153,9 +154,6 @@ export class GenerateQueueManager {
|
||||||
registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
||||||
await registerQueueManager.execute();
|
await registerQueueManager.execute();
|
||||||
|
|
||||||
const result = await registerQueueManager.getResult();
|
return registerQueueManager.getResult();
|
||||||
result.time = null;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ export class RegisterQueueManager extends BaseCreateManager<QueueModel> {
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
const vip = this.data.vip ?? false;
|
const vip = this.data.vip ?? false;
|
||||||
|
const showTime = this.data.showTime ?? true;
|
||||||
const item = await this.getItemMaster();
|
const item = await this.getItemMaster();
|
||||||
this.currentItemMaster = item;
|
this.currentItemMaster = item;
|
||||||
const [, end] = await this.queueTime(item.item_queue_id);
|
const [, end] = await this.queueTime(item.item_queue_id);
|
||||||
|
@ -56,7 +57,7 @@ export class RegisterQueueManager extends BaseCreateManager<QueueModel> {
|
||||||
|
|
||||||
Object.assign(this.data, {
|
Object.assign(this.data, {
|
||||||
status: STATUS.WAITING,
|
status: STATUS.WAITING,
|
||||||
time: end,
|
time: showTime ? end : undefined,
|
||||||
item_queue_id: item.item_queue_id,
|
item_queue_id: item.item_queue_id,
|
||||||
vip,
|
vip,
|
||||||
code,
|
code,
|
||||||
|
|
Loading…
Reference in New Issue