Skip to content

Commit

Permalink
Metric: name -> title
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jan 23, 2025
1 parent d4daf5e commit 0ee9748
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/controllers/metricController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isMetric = (obj: any): obj is Metric => {
return (
typeof obj === 'object' &&
typeof obj.identifier === 'string' &&
typeof obj.name === 'string' &&
typeof obj.title === 'string' &&
typeof obj.description === 'string' &&
(obj.orientation === MetricOrientation.Increase ||
obj.orientation === MetricOrientation.Decrease) &&
Expand Down
2 changes: 1 addition & 1 deletion src/entity/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Metric {
identifier: string;

@Column()
name: string;
title: string;

@Column()
description: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { type MigrationInterface, type QueryRunner } from "typeorm";

export class InitMigration1737614845281 implements MigrationInterface {
name = 'InitMigration1737614845281'
export class InitMigration1737626955612 implements MigrationInterface {
name = 'InitMigration1737626955612'

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, "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 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 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"))`);
await queryRunner.query(`CREATE TABLE "metric" ("id" SERIAL NOT NULL, "identifier" character varying NOT NULL, "title" 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"))`);
await queryRunner.query(`ALTER TABLE "application" ADD CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "pool" ADD CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2" FOREIGN KEY ("eligibilityCriteriaId") REFERENCES "eligibility_criteria"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "vote" ADD CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "pool" ADD CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2" FOREIGN KEY ("eligibilityCriteriaId") REFERENCES "eligibility_criteria"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`);
await queryRunner.query(`ALTER TABLE "pool" DROP CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2"`);
await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`);
await queryRunner.query(`ALTER TABLE "application" DROP CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284"`);
await queryRunner.query(`DROP TABLE "metric"`);
await queryRunner.query(`DROP TYPE "public"."metric_orientation_enum"`);
await queryRunner.query(`DROP TABLE "vote"`);
await queryRunner.query(`DROP TABLE "pool"`);
await queryRunner.query(`DROP TABLE "vote"`);
await queryRunner.query(`DROP TABLE "eligibility_criteria"`);
await queryRunner.query(`DROP TYPE "public"."eligibility_criteria_eligibilitytype_enum"`);
await queryRunner.query(`DROP TABLE "application"`);
Expand Down
12 changes: 6 additions & 6 deletions src/routes/metricRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const router = Router();
* type: string
* description: Identifier of the metric
* example: "userEngagement"
* name:
* title:
* type: string
* description: Name of the metric
* description: Title of the metric
* example: "User Engagement"
* description:
* type: string
Expand All @@ -42,7 +42,7 @@ const router = Router();
* example: true
* required:
* - identifier
* - name
* - title
* - description
* - orientation
* - enabled
Expand All @@ -51,17 +51,17 @@ const router = Router();
* summary: User Engagement Metric
* value:
* - identifier: "userEngagement"
* name: "User Engagement"
* title: "User Engagement"
* description: "Measures how users interact with the application"
* orientation: "increase"
* enabled: true
* - identifier: "twitterAge"
* name: "Twitter Account Age"
* title: "Twitter Account Age"
* description: "Measures the age of a Twitter account"
* orientation: "increase"
* enabled: true
* - identifier: "gasFees"
* name: "Gas Fees"
* title: "Gas Fees"
* description: "Measures the transaction fees on the blockchain"
* orientation: "decrease"
* enabled: true
Expand Down
4 changes: 2 additions & 2 deletions src/service/MetricService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class MetricService {
});
}

async getMetricsByNames(names: string[]): Promise<Metric[]> {
return await metricRepository.find({ where: { name: In(names) } });
async getMetricsByNames(titles: string[]): Promise<Metric[]> {
return await metricRepository.find({ where: { title: In(titles) } });
}

async getMetricsByIdentifiers(identifiers: string[]): Promise<Metric[]> {
Expand Down

0 comments on commit 0ee9748

Please sign in to comment.