Skip to content

Commit 2c5f878

Browse files
committed
Metric: name -> title
1 parent d4daf5e commit 2c5f878

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

src/controllers/metricController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const isMetric = (obj: any): obj is Metric => {
1212
return (
1313
typeof obj === 'object' &&
1414
typeof obj.identifier === 'string' &&
15-
typeof obj.name === 'string' &&
15+
typeof obj.title === 'string' &&
1616
typeof obj.description === 'string' &&
1717
(obj.orientation === MetricOrientation.Increase ||
1818
obj.orientation === MetricOrientation.Decrease) &&

src/entity/Metric.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class Metric {
1616
identifier: string;
1717

1818
@Column()
19-
name: string;
19+
title: string;
2020

2121
@Column()
2222
description: string;

src/migration/1737614845281-InitMigration.ts src/migration/1737626955612-InitMigration.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { type MigrationInterface, type QueryRunner } from "typeorm";
22

3-
export class InitMigration1737614845281 implements MigrationInterface {
4-
name = 'InitMigration1737614845281'
3+
export class InitMigration1737626955612 implements MigrationInterface {
4+
name = 'InitMigration1737626955612'
55

66
public async up(queryRunner: QueryRunner): Promise<void> {
77
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"))`);
88
await queryRunner.query(`CREATE TYPE "public"."eligibility_criteria_eligibilitytype_enum" AS ENUM('linear')`);
99
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"))`);
10-
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"))`);
1110
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"))`);
11+
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"))`);
1212
await queryRunner.query(`CREATE TYPE "public"."metric_orientation_enum" AS ENUM('increase', 'decrease')`);
13-
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"))`);
13+
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"))`);
1414
await queryRunner.query(`ALTER TABLE "application" ADD CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
15-
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`);
1615
await queryRunner.query(`ALTER TABLE "vote" ADD CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
16+
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`);
1717
}
1818

1919
public async down(queryRunner: QueryRunner): Promise<void> {
20-
await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`);
2120
await queryRunner.query(`ALTER TABLE "pool" DROP CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2"`);
21+
await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`);
2222
await queryRunner.query(`ALTER TABLE "application" DROP CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284"`);
2323
await queryRunner.query(`DROP TABLE "metric"`);
2424
await queryRunner.query(`DROP TYPE "public"."metric_orientation_enum"`);
25-
await queryRunner.query(`DROP TABLE "vote"`);
2625
await queryRunner.query(`DROP TABLE "pool"`);
26+
await queryRunner.query(`DROP TABLE "vote"`);
2727
await queryRunner.query(`DROP TABLE "eligibility_criteria"`);
2828
await queryRunner.query(`DROP TYPE "public"."eligibility_criteria_eligibilitytype_enum"`);
2929
await queryRunner.query(`DROP TABLE "application"`);

src/routes/metricRoutes.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const router = Router();
2323
* type: string
2424
* description: Identifier of the metric
2525
* example: "userEngagement"
26-
* name:
26+
* title:
2727
* type: string
28-
* description: Name of the metric
28+
* description: Title of the metric
2929
* example: "User Engagement"
3030
* description:
3131
* type: string
@@ -42,7 +42,7 @@ const router = Router();
4242
* example: true
4343
* required:
4444
* - identifier
45-
* - name
45+
* - title
4646
* - description
4747
* - orientation
4848
* - enabled
@@ -51,17 +51,17 @@ const router = Router();
5151
* summary: User Engagement Metric
5252
* value:
5353
* - identifier: "userEngagement"
54-
* name: "User Engagement"
54+
* title: "User Engagement"
5555
* description: "Measures how users interact with the application"
5656
* orientation: "increase"
5757
* enabled: true
5858
* - identifier: "twitterAge"
59-
* name: "Twitter Account Age"
59+
* title: "Twitter Account Age"
6060
* description: "Measures the age of a Twitter account"
6161
* orientation: "increase"
6262
* enabled: true
6363
* - identifier: "gasFees"
64-
* name: "Gas Fees"
64+
* title: "Gas Fees"
6565
* description: "Measures the transaction fees on the blockchain"
6666
* orientation: "decrease"
6767
* enabled: true

src/seeders/MetricSeeder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ export default class MetricSeeder extends Seeder {
1010
console.log('Database connection established.');
1111
const data: Array<Partial<Metric>> = [
1212
{
13-
name: 'Txn Number',
13+
title: 'Txn Number',
1414
description: 'Number of transactions made for project',
1515
orientation: MetricOrientation.Increase,
1616
enabled: true,
1717
},
1818
{
19-
name: 'Age',
19+
title: 'Age',
2020
description: 'Age of the project',
2121
orientation: MetricOrientation.Increase,
2222
enabled: true,
2323
},
2424
{
25-
name: 'Twitter Followers',
25+
title: 'Twitter Followers',
2626
description: 'Number of Twitter followers',
2727
orientation: MetricOrientation.Increase,
2828
enabled: false,

src/service/MetricService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class MetricService {
3030
});
3131
}
3232

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

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

0 commit comments

Comments
 (0)