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);
|
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.jobQueue.deleteAllJobs('completed');
|
||||||
await jobRunner.resetToPrevIndexedBlock();
|
await jobRunner.resetToPrevIndexedBlock();
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ export class ServerCmd {
|
|||||||
assert(eventWatcher);
|
assert(eventWatcher);
|
||||||
|
|
||||||
if (config.server.kind === KIND_ACTIVE) {
|
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 jobQueue.deleteAllJobs('completed');
|
||||||
await eventWatcher.start();
|
await eventWatcher.start();
|
||||||
}
|
}
|
||||||
|
@ -347,45 +347,46 @@ export class Entity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
entityObject.columns.forEach((column: any) => {
|
entityObject.columns.forEach((column: any) => {
|
||||||
// Implement bigintTransformer for bigint type.
|
if (column.tsType.includes('bigint')) {
|
||||||
if (column.tsType === 'bigint') {
|
// Check if it is of array type
|
||||||
column.columnOptions.push(
|
if (column.tsType.includes('bigint[]')) {
|
||||||
{
|
// Implement bigintArrayTransformer for array of bigint type.
|
||||||
option: 'transformer',
|
column.columnOptions.push(
|
||||||
value: 'bigintTransformer'
|
{
|
||||||
|
option: 'transformer',
|
||||||
|
value: 'bigintArrayTransformer'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (importObject) {
|
||||||
|
importObject.toImport.add('bigintArrayTransformer');
|
||||||
|
} else {
|
||||||
|
importObject = {
|
||||||
|
toImport: new Set(['bigintArrayTransformer']),
|
||||||
|
from: '@cerc-io/util'
|
||||||
|
};
|
||||||
|
|
||||||
|
entityObject.imports.push(importObject);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (importObject) {
|
|
||||||
importObject.toImport.add('bigintTransformer');
|
|
||||||
} else {
|
} else {
|
||||||
importObject = {
|
// Implement bigintTransformer for bigint type.
|
||||||
toImport: new Set(['bigintTransformer']),
|
column.columnOptions.push(
|
||||||
from: '@cerc-io/util'
|
{
|
||||||
};
|
option: 'transformer',
|
||||||
|
value: 'bigintTransformer'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
entityObject.imports.push(importObject);
|
if (importObject) {
|
||||||
}
|
importObject.toImport.add('bigintTransformer');
|
||||||
}
|
} else {
|
||||||
|
importObject = {
|
||||||
|
toImport: new Set(['bigintTransformer']),
|
||||||
|
from: '@cerc-io/util'
|
||||||
|
};
|
||||||
|
|
||||||
// Implement bigintArrayTransformer for array of bigint type.
|
entityObject.imports.push(importObject);
|
||||||
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,49 +400,48 @@ export class Entity {
|
|||||||
let isDecimalRequired = false;
|
let isDecimalRequired = false;
|
||||||
|
|
||||||
entityObject.columns.forEach((column: any) => {
|
entityObject.columns.forEach((column: any) => {
|
||||||
// Implement decimalTransformer for Decimal type.
|
if (column.tsType.includes('Decimal')) {
|
||||||
if (column.tsType === 'Decimal') {
|
|
||||||
isDecimalRequired = true;
|
isDecimalRequired = true;
|
||||||
|
|
||||||
column.columnOptions.push(
|
// Check if it is of array type
|
||||||
{
|
if (column.tsType.includes('Decimal[]')) {
|
||||||
option: 'transformer',
|
// Implement decimalArrayTransformer for array of Decimal type.
|
||||||
value: 'decimalTransformer'
|
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);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (importObject) {
|
|
||||||
importObject.toImport.add('decimalTransformer');
|
|
||||||
} else {
|
} else {
|
||||||
importObject = {
|
// Implement decimalTransformer for Decimal type.
|
||||||
toImport: new Set(['decimalTransformer']),
|
column.columnOptions.push(
|
||||||
from: '@cerc-io/util'
|
{
|
||||||
};
|
option: 'transformer',
|
||||||
|
value: 'decimalTransformer'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
entityObject.imports.push(importObject);
|
if (importObject) {
|
||||||
}
|
importObject.toImport.add('decimalTransformer');
|
||||||
}
|
} else {
|
||||||
|
importObject = {
|
||||||
|
toImport: new Set(['decimalTransformer']),
|
||||||
|
from: '@cerc-io/util'
|
||||||
|
};
|
||||||
|
|
||||||
// Implement decimalArrayTransformer for array of Decimal type.
|
entityObject.imports.push(importObject);
|
||||||
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));
|
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>[]]> {
|
async saveBlockAndFetchEvents (block: DeepPartial<BlockProgress>): Promise<[BlockProgress, DeepPartial<Event>[]]> {
|
||||||
return this._saveBlockAndFetchEvents(block);
|
return this._saveBlockAndFetchEvents(block);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,6 @@ export class JobRunner {
|
|||||||
} else {
|
} else {
|
||||||
// Check that startBlock is one greater than previous batch end block
|
// Check that startBlock is one greater than previous batch end block
|
||||||
if (startBlock - 1 !== this._historicalProcessingCompletedUpto) {
|
if (startBlock - 1 !== this._historicalProcessingCompletedUpto) {
|
||||||
// TODO: Debug jobQueue deleteJobs for historical processing not working
|
|
||||||
await this.jobQueue.markComplete(
|
await this.jobQueue.markComplete(
|
||||||
job,
|
job,
|
||||||
{ isComplete: false }
|
{ isComplete: false }
|
||||||
|
@ -133,6 +133,7 @@ export const resetJobs = async (config: Config): Promise<void> => {
|
|||||||
|
|
||||||
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
|
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
|
||||||
await jobQueue.start();
|
await jobQueue.start();
|
||||||
|
// Delete all active and pending (before completed) jobs
|
||||||
await jobQueue.deleteAllJobs('completed');
|
await jobQueue.deleteAllJobs('completed');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user