forked from zkLinkProtocol/nova-point-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4eed32
commit 9b7d3f4
Showing
11 changed files
with
193 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Entity, Column, Unique, Index, PrimaryColumn } from "typeorm"; | ||
import { BaseEntity } from "./base.entity"; | ||
|
||
@Entity({ name: "directHoldProcessingStatus" }) | ||
@Index(["pointProcessed"]) | ||
export class DirectHoldProcessingStatus extends BaseEntity { | ||
@PrimaryColumn() | ||
blockNumber: number; | ||
|
||
@Column({ default: false }) | ||
pointProcessed: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/migrations/1721893869511-GenerateDirectPointProcessingStatusTable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class GenerateDirectPointProcessingStatusTable1721893869511 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "directHoldProcessingStatus" ( | ||
"createdAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
"blockNumber" integer NOT NULL, | ||
"pointProcessed" boolean NOT NULL DEFAULT false, | ||
CONSTRAINT "PK_directHoldProcessingStatus" PRIMARY KEY ("blockNumber"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE INDEX "IDX_directHoldProcessingStatus_1" ON "directHoldProcessingStatus" ("pointProcessed") ` | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "public"."IDX_directHoldProcessingStatus_1"`); | ||
await queryRunner.query(`DROP TABLE "directHoldProcessingStatus"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { LrtUnitOfWork } from "../unitOfWork"; | ||
import { BaseRepository } from "./base.repository"; | ||
import { DirectHoldProcessingStatus } from "../entities"; | ||
|
||
@Injectable() | ||
export class DirectHoldProcessingStatusRepository extends BaseRepository<DirectHoldProcessingStatus> { | ||
public constructor(unitOfWork: LrtUnitOfWork) { | ||
super(DirectHoldProcessingStatus, unitOfWork); | ||
} | ||
|
||
public async upsertStatus(updateData: Partial<DirectHoldProcessingStatus>): Promise<DirectHoldProcessingStatus> { | ||
const entityManager = this.unitOfWork.getTransactionManager(); | ||
const result = await entityManager.upsert(DirectHoldProcessingStatus, updateData, ["blockNumber"]); | ||
|
||
return result.raw[0]; | ||
} | ||
|
||
public async getUnprocessedBlockNumber(): Promise<DirectHoldProcessingStatus[]> { | ||
const entityManager = this.unitOfWork.getTransactionManager(); | ||
const result = await entityManager.find(DirectHoldProcessingStatus, { | ||
where: [{ pointProcessed: false }], | ||
order: { blockNumber: "ASC" }, | ||
}); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.