Skip to content

Commit

Permalink
delete unused: statistics and account
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Apr 24, 2024
1 parent 27cc343 commit 0393d77
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 471 deletions.
11 changes: 0 additions & 11 deletions apollo/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ model HistoryRecord {
extData String?
}

model DailyStatistics {
fromChain String
toChain String
bridge String
timestamp Int
token String
dailyVolume BigInt?
dailyCount BigInt?
@@unique([fromChain, toChain, bridge, timestamp, token], name: "daily_statistics_id")
}

model LnBridgeRelayInfo {
id String @id
version String
Expand Down
7 changes: 0 additions & 7 deletions apollo/src/account/account.graphql

This file was deleted.

9 changes: 0 additions & 9 deletions apollo/src/account/account.module.ts

This file was deleted.

21 changes: 0 additions & 21 deletions apollo/src/account/account.resolver.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions apollo/src/account/account.resolver.ts

This file was deleted.

20 changes: 0 additions & 20 deletions apollo/src/account/account.service.spec.ts

This file was deleted.

44 changes: 0 additions & 44 deletions apollo/src/account/account.service.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apollo/src/aggregation/aggregation.history.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ type HistoryRecord {
extData: String
}

type DailyStatistics {
fromChain: String!
toChain: String!
bridge: String!
timestamp: Int!
token: String!
dailyVolume: BigInt
dailyCount: BigInt
}

type HistoryRecords {
total: Int!
records: [HistoryRecord]
Expand Down Expand Up @@ -106,7 +96,6 @@ type Query {
historyRecordById(id: String): HistoryRecord
historyRecordByTxHash(txHash: String): HistoryRecord
firstHistoryRecord(fromChain: String, toChain: String, bridge: String, results: [Int], relayer: String, token: String, order: String, notsubmited: Boolean): HistoryRecord
queryDailyStatistics(timepast: Int!, first: Int, from: String, to: String, bridge: String, token: String): [DailyStatistics]
historyRecords(sender: String, recipient: String, relayer: String, needWithdrawLiquidity: Boolean, fromChains: [String], toChains: [String], bridges: [String], row: Int, page: Int, results: [Int], recvTokenAddress: String, order: String): HistoryRecords
checkLnBridgeExist(fromChainId: Int, toChainId: Int, fromToken: String, toToken: String, version: String): Boolean
tasksHealthCheck(name: String): [HealthInfo]
Expand Down
33 changes: 0 additions & 33 deletions apollo/src/aggregation/aggregation.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,39 +160,6 @@ export class AggregationResolver {
});
}

// daily statistics
@Query()
async queryDailyStatistics(
@Args('timepast') timepast: number,
@Args('first') take: number,
@Args('from') fromChain: string,
@Args('to') toChain: string,
@Args('bridge') bridge: string,
@Args('token') token: string
) {
const filter = [];
if (fromChain) {
filter.push({ fromChain });
}
if (toChain) {
filter.push({ toChain });
}
if (bridge) {
filter.push({ bridge });
}
if (token) {
filter.push({ token });
}

const now = Date.now() / 1000;
const timelimit = Math.floor(now - timepast);
const where = { AND: { timestamp: { gt: timelimit }, AND: filter } };
return this.aggregationService.queryDailyStatistics({
take,
where,
});
}

/**
* @deprecated instead, please use signConfirmedBlock
**/
Expand Down
44 changes: 1 addition & 43 deletions apollo/src/aggregation/aggregation.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { INestApplication, Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { DailyStatistics, HistoryRecord, Prisma, PrismaClient } from '@prisma/client';
import { HistoryRecord, Prisma, PrismaClient } from '@prisma/client';
import { HistoryRecords, LnBridgeRelayInfo, LnBridgeRelayInfos } from '../graphql';
// export lnbridge service configure
import { last } from 'lodash';
Expand Down Expand Up @@ -165,39 +165,6 @@ export class AggregationService extends PrismaClient implements OnModuleInit {
return { total, records };
}

// daily statistics
async createDailyStatistics(data: Prisma.DailyStatisticsCreateInput): Promise<DailyStatistics> {
return this.dailyStatistics.create({
data,
});
}

async updateDailyStatistics(params: {
where: Prisma.DailyStatisticsWhereUniqueInput;
data: Prisma.DailyStatisticsUpdateInput;
}): Promise<DailyStatistics> {
const { where, data } = params;
return this.dailyStatistics.update({
data,
where,
});
}

async queryDailyStatistics(params: {
skip?: number;
take?: number;
where?: Prisma.DailyStatisticsWhereInput;
}): Promise<DailyStatistics[]> {
const { skip, take, where } = params;

return this.dailyStatistics.findMany({
skip,
take,
where,
orderBy: { timestamp: 'desc' },
});
}

tasksHealthCheck() {
return this.tasksService.queryHealthChecks();
}
Expand Down Expand Up @@ -300,15 +267,6 @@ export class AggregationService extends PrismaClient implements OnModuleInit {
}
}

async queryDailyStatisticsFirst(
dailyStatisticsWhereInput: Prisma.DailyStatisticsWhereInput
): Promise<DailyStatistics | null> {
return this.dailyStatistics.findFirst({
where: dailyStatisticsWhereInput,
orderBy: { timestamp: 'desc' },
});
}

async calculateLnBridgeRelayerPoint(
token: string,
amount: bigint,
Expand Down
4 changes: 0 additions & 4 deletions apollo/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { GraphQLModule, Scalar } from '@nestjs/graphql';
import { ScheduleModule } from '@nestjs/schedule';
import BigInt from 'apollo-type-bigint';
import { join } from 'path';
import { AccountModule } from './account/account.module';
import { AggregationModule } from './aggregation/aggregation.module';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TasksModule } from './tasks/tasks.module';
import { StatisticModule } from './statistic/statistic.module';
import { Lnv2Module } from './lnv2/lnv2.module';
import { Lnv3Module } from './lnv3/lnv3.module';

Expand All @@ -29,15 +27,13 @@ export class BigIntScalar extends BigInt {}
outputAs: 'class',
},
}),
AccountModule,
ConfigModule.forRoot({
envFilePath: ['.env', chainEnvFilePath],
isGlobal: true,
}),
ScheduleModule.forRoot(),
TasksModule,
AggregationModule,
StatisticModule,
Lnv2Module,
Lnv3Module,
],
Expand Down
21 changes: 0 additions & 21 deletions apollo/src/filter/http-exception.filter.ts

This file was deleted.

Loading

0 comments on commit 0393d77

Please sign in to comment.