Commit e65ebee7 authored by velayat's avatar velayat
Browse files

add show result rest api

parent fbb24753
This diff is collapsed.
...@@ -4,20 +4,18 @@ import { GetUserScore } from './dto/get-user-score'; ...@@ -4,20 +4,18 @@ import { GetUserScore } from './dto/get-user-score';
@Controller() @Controller()
export class AppController { export class AppController {
constructor(private readonly appService: AppService) { } constructor(private readonly appService: AppService) {}
@Get('get-comments')
async getCommentsFromIG() {
return await this.appService.getComments();
}
// @Get('get-comments')
// async getCommentsFromIG() {
// return await this.appService.getComments();
// }
@Get('get-followers') @Get('get-followers')
async getFollowers() { async getFollowers() {
return await this.appService.getFollowers(); return await this.appService.getFollowers();
} }
@Post() @Post()
async getUserScore(@Body() getUserScoreDto: GetUserScore) { async getUserScore(@Body() getUserScoreDto: GetUserScore) {
return await this.appService.calculateUserScore(getUserScoreDto.username); return await this.appService.calculateUserScore(getUserScoreDto.username);
...@@ -25,7 +23,7 @@ export class AppController { ...@@ -25,7 +23,7 @@ export class AppController {
@Get('calculate-result') @Get('calculate-result')
async calculateResult() { async calculateResult() {
return await this.appService.getResults() return await this.appService.getResults();
} }
@Get('get-results') @Get('get-results')
...@@ -40,12 +38,16 @@ export class AppController { ...@@ -40,12 +38,16 @@ export class AppController {
@Get('shuffle') @Get('shuffle')
async shuffle() { async shuffle() {
return await this.appService.getShuffleData() return await this.appService.getShuffleData();
} }
@Get('add-lottory-result') @Get('add-lottory-result')
async addResultDb() { async addResultDb() {
return await this.appService.addResultsToDB() return await this.appService.addResultsToDB();
}
@Get('get-lottory-result')
async getResultDb() {
return await this.appService.getResultDb();
} }
} }
...@@ -36,7 +36,8 @@ export class AppService implements OnApplicationBootstrap { ...@@ -36,7 +36,8 @@ export class AppService implements OnApplicationBootstrap {
) {} ) {}
async onApplicationBootstrap() { async onApplicationBootstrap() {
this.client = await this.login('sohe.ibs', 'kaka1374'); this.client = await this.login('shahriarvelayat', 'shve8864@@');
// this.client = null
} }
private async login(username, password) { private async login(username, password) {
...@@ -665,6 +666,10 @@ export class AppService implements OnApplicationBootstrap { ...@@ -665,6 +666,10 @@ export class AppService implements OnApplicationBootstrap {
await this.lotoryResultModel.insertMany(comptitionArray); await this.lotoryResultModel.insertMany(comptitionArray);
return 'successfull'; return 'successfull';
} }
async getResultDb() {
return await this.lotoryResultModel.find().select({username:1,index:1});
}
} }
export class ResultResponse { export class ResultResponse {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment