Commit 0c9235d1 authored by soheib's avatar soheib
Browse files

merge

parents bded2cd7 38b34484
export class CalculateScoreDto{
profile_username: string
post_array: string[]
export class CalculateScoreDto{
profile_username: string
post_array: string[]
}
\ No newline at end of file
export class ChangeStatusDto{
mobile: string
username: string
export class ChangeStatusDto{
mobile: string
username: string
}
\ No newline at end of file
export class WeeklySearchDto {
username: string
profile_username: string
post_array: string[]
export class WeeklySearchDto {
username: string
profile_username: string
post_array: string[]
}
\ No newline at end of file
import { Body, Query, Controller, Get, Post } from '@nestjs/common';
import { CalculateScoreDto } from './dto/calculate-score-dto'
import { ChangeStatusDto } from './dto/change-status-dto'
import { WeeklySearchDto } from './dto/weekly-search-dto'
import { LotteryService } from './lottery.service';
@Controller('lottery')
export class LotteryController {
constructor(private lotteryService: LotteryService) { }
//weekly lottery apies:
@Post('weekly/search')
async getUserResults(@Body() searchDto: WeeklySearchDto) {
return await this.lotteryService.getUserScore(searchDto.username,
searchDto.profile_username, searchDto.post_array)
}
@Post('weekly/calculate-score')
async addResultsToDb(@Body() calculateScoreDto: CalculateScoreDto) {
return await this.lotteryService.addResultsToDB(calculateScoreDto.profile_username,
calculateScoreDto.post_array)
}
@Get('weekly/get-lottory-result')
async getResultDb() {
return await this.lotteryService.getResultDb()
}
@Post('weekly/change-status')
async changeStatus(@Body() changeStatusDto: ChangeStatusDto) {
console.log('here');
return await this.lotteryService.changeStatus(changeStatusDto)
}
}
import { Body, Query, Controller, Get, Post } from '@nestjs/common';
import { CalculateScoreDto } from './dto/calculate-score-dto'
import { ChangeStatusDto } from './dto/change-status-dto'
import { WeeklySearchDto } from './dto/weekly-search-dto'
import { LotteryService } from './lottery.service';
@Controller('lottery')
export class LotteryController {
constructor(private lotteryService: LotteryService) { }
//weekly lottery apies:
@Post('weekly/search')
async getUserResults(@Body() searchDto: WeeklySearchDto) {
return await this.lotteryService.getUserScore(searchDto.username,
searchDto.profile_username, searchDto.post_array)
}
@Post('weekly/calculate-score')
async addResultsToDb(@Body() calculateScoreDto: CalculateScoreDto) {
return await this.lotteryService.addResultsToDB(calculateScoreDto.profile_username,
calculateScoreDto.post_array)
}
@Get('weekly/get-lottory-result')
async getResultDb() {
return await this.lotteryService.getResultDb()
}
@Post('weekly/change-status')
async changeStatus(@Body() changeStatusDto: ChangeStatusDto) {
console.log('here');
return await this.lotteryService.changeStatus(changeStatusDto)
}
}
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
})
await app.listen(4002).then(() => {
console.log(`server start on port 4002`);
})
}
bootstrap();
1import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
})
await app.listen(4001).then(() => {
console.log(`server start on port 4001`);
})
}
bootstrap();
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type RequestDocument = Request & Document;
@Schema({ timestamps: true })
export class Request {
@Prop()
_id: Types.ObjectId;
@Prop()
cursor: string;
@Prop()
type: string;
@Prop()
post_short_code: string;
@Prop()
account_username: string;
}
export const RequestSchema = SchemaFactory.createForClass(Request);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type RequestDocument = Request & Document;
@Schema({ timestamps: true })
export class Request {
@Prop()
_id: Types.ObjectId;
@Prop()
cursor: string;
@Prop()
type: string;
@Prop()
post_short_code: string;
@Prop()
account_username: string;
}
export const RequestSchema = SchemaFactory.createForClass(Request);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type ResultDocument = Result & Document;
@Schema({ timestamps: true })
export class Result {
@Prop()
username: string;
@Prop()
valid_mentions: number;
@Prop()
mentions_before: number;
@Prop()
followed_before: number;
@Prop()
pending_mentions: number;
@Prop()
score: number;
@Prop()
valid_users: Array<string>;
@Prop()
mentions_before_users: Array<string>;
@Prop()
followed_before_users: Array<string>;
@Prop()
pending_users: Array<string>;
}
export const ResultSchema = SchemaFactory.createForClass(Result);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type ResultDocument = Result & Document;
@Schema({ timestamps: true })
export class Result {
@Prop()
username: string;
@Prop()
valid_mentions: number;
@Prop()
mentions_before: number;
@Prop()
followed_before: number;
@Prop()
pending_mentions: number;
@Prop()
score: number;
@Prop()
valid_users: Array<string>;
@Prop()
mentions_before_users: Array<string>;
@Prop()
followed_before_users: Array<string>;
@Prop()
pending_users: Array<string>;
}
export const ResultSchema = SchemaFactory.createForClass(Result);
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