Skip to content

Commit

Permalink
adapter questN
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Oct 30, 2024
1 parent 9f9d0fb commit 62a2180
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
30 changes: 29 additions & 1 deletion apollo/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Query } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
Expand All @@ -9,4 +9,32 @@ export class AppController {
getHello(): string {
return this.appService.getHello();
}

@Get('questn/used')
async questNUsedHelix(@Query('address') address: string) {
return await this.appService.questNUsedHelix(
{
sender: address.toLowerCase(),
},
1
);
}

@Get('questn/usedafter')
async questNUsedAfter(@Query('address') address: string) {
const where = {
sender: address.toLowerCase(),
startTime: { gt: 1729428516 },
};
return await this.appService.questNUsedHelix(where, 1);
}

@Get('questn/afterand3times')
async questNUsedAfterAnd3Times(@Query('address') address: string) {
const where = {
sender: address.toLowerCase(),
startTime: { gt: 1729428516 },
};
return await this.appService.questNUsedHelix(where, 3);
}
}
26 changes: 25 additions & 1 deletion apollo/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import { Injectable } from '@nestjs/common';
import { HistoryRecord, Prisma, PrismaClient } from '@prisma/client';

@Injectable()
export class AppService {
export class AppService extends PrismaClient {
getHello(): string {
return 'Hello World!';
}

async questNUsedHelix(where: Prisma.HistoryRecordWhereInput, times: number) {
const total = await this.historyRecord.count({
where,
});
if (total >= times) {
return {
data: {
result: true,
},
};
} else {
return {
error: {
code: 0,
message: `user sent count ${total}`,
},
data: {
result: false,
},
};
}
}
}

0 comments on commit 62a2180

Please sign in to comment.