Skip to content

Commit

Permalink
add lastUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jan 21, 2025
1 parent e804283 commit 7786aec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/entity/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { Application } from '@/entity/Application';
import { EligibilityCriteria } from './EligibilityCriteria';
import { Vote } from './Vote';

export interface DistributionData {
lastUpdated: string;
distribution: Distribution[];
}

export interface Distribution {
alloApplicationId: string;
distribution_percentage: number;
Expand Down Expand Up @@ -42,5 +47,5 @@ export class Pool {
votes: Vote[];

@Column('simple-json', { nullable: true })
distribution: Distribution[];
distributionData: DistributionData;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type MigrationInterface, type QueryRunner } from "typeorm";

export class InitMigration1737003698259 implements MigrationInterface {
name = 'InitMigration1737003698259'
export class InitMigration1737442159430 implements MigrationInterface {
name = 'InitMigration1737442159430'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "application" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloApplicationId" character varying NOT NULL, "poolId" integer NOT NULL, CONSTRAINT "UQ_8849159f2a2681f6be67ef84efb" UNIQUE ("alloApplicationId", "poolId"), CONSTRAINT "PK_569e0c3e863ebdf5f2408ee1670" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TYPE "public"."eligibility_criteria_eligibilitytype_enum" AS ENUM('linear')`);
await queryRunner.query(`CREATE TABLE "eligibility_criteria" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "eligibilityType" "public"."eligibility_criteria_eligibilitytype_enum" NOT NULL, "data" json NOT NULL, CONSTRAINT "UQ_cab3614863337cf5dba521b9b84" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "PK_231ea7a8a87bb6092eb3af1c5a8" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "pool" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "metricIdentifiers" text, "distribution" text, "eligibilityCriteriaId" integer, CONSTRAINT "UQ_72fcaa655b2b7348f4feaf25ea3" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "REL_bb4a5f9f4367c3de6ccaf665cc" UNIQUE ("eligibilityCriteriaId"), CONSTRAINT "PK_db1bfe411e1516c01120b85f8fe" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "pool" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "metricIdentifiers" text, "distributionData" text, "eligibilityCriteriaId" integer, CONSTRAINT "UQ_72fcaa655b2b7348f4feaf25ea3" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "REL_bb4a5f9f4367c3de6ccaf665cc" UNIQUE ("eligibilityCriteriaId"), CONSTRAINT "PK_db1bfe411e1516c01120b85f8fe" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "vote" ("id" SERIAL NOT NULL, "voter" character varying(42) NOT NULL, "alloPoolId" character varying NOT NULL, "chainId" integer NOT NULL, "ballot" text NOT NULL, "poolId" integer NOT NULL, CONSTRAINT "UQ_3940f20660f872bfe5386def7f1" UNIQUE ("poolId", "voter"), CONSTRAINT "PK_2d5932d46afe39c8176f9d4be72" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TYPE "public"."metric_orientation_enum" AS ENUM('increase', 'decrease')`);
await queryRunner.query(`CREATE TABLE "metric" ("id" SERIAL NOT NULL, "identifier" character varying NOT NULL, "name" character varying NOT NULL, "description" character varying NOT NULL, "orientation" "public"."metric_orientation_enum" NOT NULL, "enabled" boolean NOT NULL DEFAULT false, CONSTRAINT "UQ_1136bb423acf02b4e7e5c909d0c" UNIQUE ("identifier"), CONSTRAINT "PK_7d24c075ea2926dd32bd1c534ce" PRIMARY KEY ("id"))`);
Expand Down
5 changes: 4 additions & 1 deletion src/service/PoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class PoolService {
if (pool == null) {
throw new NotFoundError('Pool not found');
}
pool.distribution = distribution;
pool.distributionData = {
lastUpdated: new Date().toUTCString(),
distribution,
};
return await this.savePool(pool);
}
}
Expand Down

0 comments on commit 7786aec

Please sign in to comment.