mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-29 03:12:10 +00:00
Remove eventName filter in events count query (#220)
This commit is contained in:
parent
3862f9ce2e
commit
ecd8b2474a
@ -544,7 +544,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let entities = await selectQueryBuilder.getRawMany();
|
let entities = await selectQueryBuilder.getRawMany();
|
||||||
entities = await this._transformResults(queryRunner, repo.createQueryBuilder('subTable'), entities);
|
entities = await this.transformResults(queryRunner, repo.createQueryBuilder('subTable'), entities);
|
||||||
|
|
||||||
return entities as Entity[];
|
return entities as Entity[];
|
||||||
}
|
}
|
||||||
@ -670,7 +670,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let entities = await selectQueryBuilder.getRawMany();
|
let entities = await selectQueryBuilder.getRawMany();
|
||||||
entities = await this._transformResults(queryRunner, repo.createQueryBuilder('subTable'), entities);
|
entities = await this.transformResults(queryRunner, repo.createQueryBuilder('subTable'), entities);
|
||||||
|
|
||||||
return entities as Entity[];
|
return entities as Entity[];
|
||||||
}
|
}
|
||||||
@ -1185,7 +1185,7 @@ export class Database {
|
|||||||
cachePrunedEntitiesCount.set(totalEntities);
|
cachePrunedEntitiesCount.set(totalEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _transformResults<Entity> (queryRunner: QueryRunner, qb: SelectQueryBuilder<Entity>, rawResults: any[]): Promise<any[]> {
|
async transformResults<Entity> (queryRunner: QueryRunner, qb: SelectQueryBuilder<Entity>, rawResults: any[]): Promise<any[]> {
|
||||||
const transformer = new RawSqlResultsToEntityTransformer(
|
const transformer = new RawSqlResultsToEntityTransformer(
|
||||||
qb.expressionMap,
|
qb.expressionMap,
|
||||||
queryRunner.manager.connection.driver,
|
queryRunner.manager.connection.driver,
|
||||||
|
@ -71,8 +71,6 @@ export class Database {
|
|||||||
_config: ConnectionOptions
|
_config: ConnectionOptions
|
||||||
_conn!: Connection
|
_conn!: Connection
|
||||||
_pgPool: Pool
|
_pgPool: Pool
|
||||||
_blockCount = 0
|
|
||||||
_eventCount = 0
|
|
||||||
|
|
||||||
constructor (config: ConnectionOptions) {
|
constructor (config: ConnectionOptions) {
|
||||||
assert(config);
|
assert(config);
|
||||||
@ -181,8 +179,7 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveBlockProgress (repo: Repository<BlockProgressInterface>, block: DeepPartial<BlockProgressInterface>): Promise<BlockProgressInterface> {
|
async saveBlockProgress (repo: Repository<BlockProgressInterface>, block: DeepPartial<BlockProgressInterface>): Promise<BlockProgressInterface> {
|
||||||
this._blockCount++;
|
blockProgressCount.inc(1);
|
||||||
blockProgressCount.set(this._blockCount);
|
|
||||||
|
|
||||||
return await repo.save(block);
|
return await repo.save(block);
|
||||||
}
|
}
|
||||||
@ -275,8 +272,7 @@ export class Database {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const blockProgress = await blockRepo.save(entity);
|
const blockProgress = await blockRepo.save(entity);
|
||||||
this._blockCount++;
|
blockProgressCount.inc(1);
|
||||||
blockProgressCount.set(this._blockCount);
|
|
||||||
|
|
||||||
// Bulk insert events.
|
// Bulk insert events.
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
@ -301,8 +297,8 @@ export class Database {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(insertPromises);
|
await Promise.all(insertPromises);
|
||||||
this._eventCount += events.filter(event => event.eventName !== UNKNOWN_EVENT_NAME).length;
|
const knownEvents = events.filter(event => event.eventName !== UNKNOWN_EVENT_NAME).length;
|
||||||
eventCount.set(this._eventCount);
|
eventCount.inc(knownEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEntities<Entity> (queryRunner: QueryRunner, entity: new () => Entity, findConditions?: FindManyOptions<Entity>): Promise<Entity[]> {
|
async getEntities<Entity> (queryRunner: QueryRunner, entity: new () => Entity, findConditions?: FindManyOptions<Entity>): Promise<Entity[]> {
|
||||||
@ -411,8 +407,7 @@ export class Database {
|
|||||||
|
|
||||||
async saveEventEntity (repo: Repository<EventInterface>, entity: EventInterface): Promise<EventInterface> {
|
async saveEventEntity (repo: Repository<EventInterface>, entity: EventInterface): Promise<EventInterface> {
|
||||||
const event = await repo.save(entity);
|
const event = await repo.save(entity);
|
||||||
this._eventCount++;
|
eventCount.inc(1);
|
||||||
eventCount.set(this._eventCount);
|
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
@ -869,20 +864,16 @@ export class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _fetchBlockCount (): Promise<void> {
|
async _fetchBlockCount (): Promise<void> {
|
||||||
this._blockCount = await this._conn.getRepository('block_progress')
|
const res = await this._conn.getRepository('block_progress')
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
blockProgressCount.set(this._blockCount);
|
blockProgressCount.set(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _fetchEventCount (): Promise<void> {
|
async _fetchEventCount (): Promise<void> {
|
||||||
this._eventCount = await this._conn.getRepository('event')
|
const res = await this._conn.getRepository('event')
|
||||||
.count({
|
.count();
|
||||||
where: {
|
|
||||||
eventName: Not(UNKNOWN_EVENT_NAME)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
eventCount.set(this._eventCount);
|
eventCount.set(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user