mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-08 12:28:05 +00:00
Fix bigint and decimal transformers not added for null type entity field in codegen (#451)
This commit is contained in:
parent
d5c92aa150
commit
dd92b4feb2
@ -108,6 +108,7 @@ export class JobRunnerCmd {
|
||||
|
||||
const jobRunner = new JobRunner(config.jobQueue, indexer, jobQueue);
|
||||
|
||||
// Delete all active and pending (before completed) jobs to start job-runner without old queued jobs
|
||||
await jobRunner.jobQueue.deleteAllJobs('completed');
|
||||
await jobRunner.resetToPrevIndexedBlock();
|
||||
|
||||
|
@ -281,7 +281,7 @@ export class ServerCmd {
|
||||
assert(eventWatcher);
|
||||
|
||||
if (config.server.kind === KIND_ACTIVE) {
|
||||
// Delete jobs before completed state to prevent creating jobs after completion of processing previous block.
|
||||
// Delete all active and pending (before completed) jobs to prevent creating jobs after completion of processing previous block
|
||||
await jobQueue.deleteAllJobs('completed');
|
||||
await eventWatcher.start();
|
||||
}
|
||||
|
@ -347,8 +347,29 @@ export class Entity {
|
||||
});
|
||||
|
||||
entityObject.columns.forEach((column: any) => {
|
||||
if (column.tsType.includes('bigint')) {
|
||||
// Check if it is of array type
|
||||
if (column.tsType.includes('bigint[]')) {
|
||||
// Implement bigintArrayTransformer for array of bigint type.
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
value: 'bigintArrayTransformer'
|
||||
}
|
||||
);
|
||||
|
||||
if (importObject) {
|
||||
importObject.toImport.add('bigintArrayTransformer');
|
||||
} else {
|
||||
importObject = {
|
||||
toImport: new Set(['bigintArrayTransformer']),
|
||||
from: '@cerc-io/util'
|
||||
};
|
||||
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
} else {
|
||||
// Implement bigintTransformer for bigint type.
|
||||
if (column.tsType === 'bigint') {
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
@ -367,26 +388,6 @@ export class Entity {
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
}
|
||||
|
||||
// Implement bigintArrayTransformer for array of bigint type.
|
||||
if (column.tsType === 'bigint[]') {
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
value: 'bigintArrayTransformer'
|
||||
}
|
||||
);
|
||||
|
||||
if (importObject) {
|
||||
importObject.toImport.add('bigintArrayTransformer');
|
||||
} else {
|
||||
importObject = {
|
||||
toImport: new Set(['bigintArrayTransformer']),
|
||||
from: '@cerc-io/util'
|
||||
};
|
||||
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -399,10 +400,31 @@ export class Entity {
|
||||
let isDecimalRequired = false;
|
||||
|
||||
entityObject.columns.forEach((column: any) => {
|
||||
// Implement decimalTransformer for Decimal type.
|
||||
if (column.tsType === 'Decimal') {
|
||||
if (column.tsType.includes('Decimal')) {
|
||||
isDecimalRequired = true;
|
||||
|
||||
// Check if it is of array type
|
||||
if (column.tsType.includes('Decimal[]')) {
|
||||
// Implement decimalArrayTransformer for array of Decimal type.
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
value: 'decimalArrayTransformer'
|
||||
}
|
||||
);
|
||||
|
||||
if (importObject) {
|
||||
importObject.toImport.add('decimalArrayTransformer');
|
||||
} else {
|
||||
importObject = {
|
||||
toImport: new Set(['decimalArrayTransformer']),
|
||||
from: '@cerc-io/util'
|
||||
};
|
||||
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
} else {
|
||||
// Implement decimalTransformer for Decimal type.
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
@ -421,28 +443,6 @@ export class Entity {
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
}
|
||||
|
||||
// Implement decimalArrayTransformer for array of Decimal type.
|
||||
if (column.tsType === 'Decimal[]') {
|
||||
isDecimalRequired = true;
|
||||
|
||||
column.columnOptions.push(
|
||||
{
|
||||
option: 'transformer',
|
||||
value: 'decimalArrayTransformer'
|
||||
}
|
||||
);
|
||||
|
||||
if (importObject) {
|
||||
importObject.toImport.add('decimalArrayTransformer');
|
||||
} else {
|
||||
importObject = {
|
||||
toImport: new Set(['decimalArrayTransformer']),
|
||||
from: '@cerc-io/util'
|
||||
};
|
||||
|
||||
entityObject.imports.push(importObject);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -661,6 +661,14 @@ export class Indexer implements IndexerInterface {
|
||||
return this._baseIndexer.fetchEventsAndSaveBlocks(blocks, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
|
||||
}
|
||||
|
||||
async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{ blockProgress: BlockProgress, events: DeepPartial<Event>[] }[]> {
|
||||
return this._baseIndexer.fetchAndSaveFilteredEventsAndBlocks(startBlock, endBlock, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
|
||||
}
|
||||
|
||||
async fetchEventsForContracts (blockHash: string, blockNumber: number, addresses: string[]): Promise<DeepPartial<Event>[]> {
|
||||
return this._baseIndexer.fetchEventsForContracts(blockHash, blockNumber, addresses, this._eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
|
||||
}
|
||||
|
||||
async saveBlockAndFetchEvents (block: DeepPartial<BlockProgress>): Promise<[BlockProgress, DeepPartial<Event>[]]> {
|
||||
return this._saveBlockAndFetchEvents(block);
|
||||
}
|
||||
|
@ -171,7 +171,6 @@ export class JobRunner {
|
||||
} else {
|
||||
// Check that startBlock is one greater than previous batch end block
|
||||
if (startBlock - 1 !== this._historicalProcessingCompletedUpto) {
|
||||
// TODO: Debug jobQueue deleteJobs for historical processing not working
|
||||
await this.jobQueue.markComplete(
|
||||
job,
|
||||
{ isComplete: false }
|
||||
|
@ -133,6 +133,7 @@ export const resetJobs = async (config: Config): Promise<void> => {
|
||||
|
||||
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
|
||||
await jobQueue.start();
|
||||
// Delete all active and pending (before completed) jobs
|
||||
await jobQueue.deleteAllJobs('completed');
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user