Commit fbb24753 authored by shahriar's avatar shahriar
Browse files

fix bug

parent 24ac4281
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type LottoryResultDocument = LottoryResult & Document
export type LottoryResultDocument = LottoryResult & Document;
@Schema({timestamps:true})
@Schema({ timestamps: true })
export class LottoryResult {
@Prop()
username: string
username: string;
@Prop()
index: number
index: number;
}
export const LottoryResultSchema = SchemaFactory.createForClass(LottoryResult)
export const LottoryResultSchema = SchemaFactory.createForClass(LottoryResult);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type AccountFollowersDocument = AccountFollowers & Document
export type AccountFollowersDocument = AccountFollowers & Document;
@Schema({timestamps:true})
@Schema({ timestamps: true })
export class AccountFollowers {
@Prop()
_id: Types.ObjectId
_id: Types.ObjectId;
@Prop()
username: string
username: string;
@Prop()
user_id: string
user_id: string;
@Prop()
full_name: string
full_name: string;
@Prop()
bussines_username: string
bussines_username: string;
@Prop({type:Object})
follower_obejct: Object
@Prop({ type: Object })
follower_obejct: Object;
@Prop()
follow_date: number
follow_date: number;
}
export const AccountFollowersSchema = SchemaFactory.createForClass(AccountFollowers)
export const AccountFollowersSchema =
SchemaFactory.createForClass(AccountFollowers);
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { Body, Controller, Get, Post } from '@nestjs/common';
import { AppService } from './app.service';
import { GetUserScore } from './dto/get-user-score';
@Controller()
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-followers')
async getFollowers() {
return await this.appService.getFollowers();
}
@Post()
async getUserScore(@Body() getUserScoreDto: GetUserScore) {
return await this.appService.calculateUserScore(getUserScoreDto.username);
......@@ -23,7 +25,7 @@ export class AppController {
@Get('calculate-result')
async calculateResult() {
return await this.appService.getResults();
return await this.appService.getResults()
}
@Get('get-results')
......@@ -31,18 +33,19 @@ export class AppController {
return await this.appService.getFinalResults();
}
@Get('search2/:id')
async getUserResults(@Param('id') id: string) {
return await this.appService.getUserResult(id);
@Post('search')
async getUserResults(@Body('username') username: string) {
return await this.appService.getUserResult(username);
}
@Get('shuffle')
async shuffle() {
return await this.appService.getShuffleData();
return await this.appService.getShuffleData()
}
@Get('add-lottory-result')
async addResultDb() {
return await this.appService.addResultsToDB();
return await this.appService.addResultsToDB()
}
}
import { Module, OnApplicationBootstrap, } from '@nestjs/common';
import { Module, OnApplicationBootstrap } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { AccountFollowersSchema } from './account.followers';
import { AppController } from './app.controller';
......@@ -10,15 +10,20 @@ import { ResultSchema } from './result.schema';
@Module({
imports: [
MongooseModule.forRoot('mongodb://netware:Netware%40408009@185.231.180.248:27017/instagram-lottry?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=admin&authMechanism=SCRAM-SHA-256'),
MongooseModule.forRoot(
'mongodb://netware:Netware%40408009@185.231.180.248:27017/instagram-lottry?serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=admin&authMechanism=SCRAM-SHA-256',
),
MongooseModule.forFeature([{ name: 'Request', schema: RequestSchema }]),
MongooseModule.forFeature([{ name: 'Comment', schema: CommentSchema }]),
MongooseModule.forFeature([{ name: 'Result', schema: ResultSchema }]),
MongooseModule.forFeature([{ name: 'LottoryResult', schema: LottoryResultSchema }]),
MongooseModule.forFeature([{ name: 'AccountFollower', schema: AccountFollowersSchema }]),
MongooseModule.forFeature([
{ name: 'LottoryResult', schema: LottoryResultSchema },
]),
MongooseModule.forFeature([
{ name: 'AccountFollower', schema: AccountFollowersSchema },
]),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
This diff is collapsed.
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type CommentDocument = Comment & Document
export type CommentDocument = Comment & Document;
@Schema({timestamps:true})
@Schema({ timestamps: true })
export class Comment {
@Prop()
_id: Types.ObjectId
_id: Types.ObjectId;
@Prop()
comment_id: string
comment_id: string;
@Prop()
text: string
text: string;
@Prop()
owner_username : string
owner_username: string;
@Prop()
owner_id : string
owner_id: string;
@Prop()
date: number
@Prop({type:Object})
comment_object : Object
date: number;
@Prop({ type: Object })
comment_object: Object;
}
export const CommentSchema = SchemaFactory.createForClass(Comment)
export const CommentSchema = SchemaFactory.createForClass(Comment);
export class GetUserScore {
username:string
}
\ No newline at end of file
username: string;
}
This diff is collapsed.
export class CleanedComments{
owner_username: string
mentions : Array<MentionDocument>
export class CleanedComments {
owner_username: string;
mentions: Array<MentionDocument>;
}
export class MentionDocument{
mentioned_username: string
date: number
}
\ No newline at end of file
export class MentionDocument {
mentioned_username: string;
date: number;
}
export interface IFollower{
user_id: string
username: string
full_name: string
follower_obejct: Object
follow_data?: number
}
\ No newline at end of file
export interface IFollower {
user_id: string;
username: string;
full_name: string;
follower_obejct: Object;
follow_data?: number;
}
export interface IncomingComment {
comment_id: string
owner_username: string
owner_id: string
text: string
date: number
commnet_object : Object
}
\ No newline at end of file
comment_id: string;
owner_username: string;
owner_id: string;
text: string;
date: number;
commnet_object: Object;
}
export class UserAllMention {
mentioned_username: string
mentioned_user_id: string
page_follow_date: number
comment_date: number
comment_status?: CommentStatus[]
mentioned_username: string;
mentioned_user_id: string;
page_follow_date: number;
comment_date: number;
comment_status?: CommentStatus[];
}
export enum CommentStatus {
isMentionedBefore ="isMentionedBefore", //"this username was mentioned already before your comment",
isAFollowerBefore = "isAFollowerBefore", //"this username was followed page before your comment",
notFollower = "notFollower", //"this username didnt follow page yet",
isValid = "isValid", //"your comment is valid"
inValid ="inValid (mentioned before or followed before)"
}
\ No newline at end of file
isMentionedBefore = 'isMentionedBefore', //"this username was mentioned already before your comment",
isAFollowerBefore = 'isAFollowerBefore', //"this username was followed page before your comment",
notFollower = 'notFollower', //"this username didnt follow page yet",
isValid = 'isValid', //"your comment is valid"
inValid = 'inValid (mentioned before or followed before)',
}
......@@ -2,14 +2,13 @@ import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule,{ cors: true });
const app = await NestFactory.create(AppModule, { cors: true });
app.enableCors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
})
});
await app.listen(3000);
}
bootstrap();
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type RequestDocument = Request & Document
export type RequestDocument = Request & Document;
@Schema({timestamps:true})
@Schema({ timestamps: true })
export class Request {
@Prop()
_id: Types.ObjectId
_id: Types.ObjectId;
@Prop()
cursor: string
cursor: string;
@Prop()
type: string
type: string;
@Prop()
post_short_code: string
post_short_code: string;
@Prop()
account_username: string
account_username: string;
}
export const RequestSchema = SchemaFactory.createForClass(Request)
export const RequestSchema = SchemaFactory.createForClass(Request);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type ResultDocument = Result & Document
export type ResultDocument = Result & Document;
@Schema({ timestamps: true })
export class Result {
@Prop()
username: string;
@Prop()
username: string
@Prop()
valid_mentions: number;
@Prop()
valid_mentions: number
@Prop()
invalid_mentions: number;
@Prop()
invalid_mentions: number
@Prop()
pending_mentions: number;
@Prop()
pending_mentions: number
@Prop()
score: number;
@Prop()
score: number
@Prop()
valid_users: Array<string>
@Prop()
inValid_users: Array<string>
@Prop()
pending_users: Array<string>
@Prop()
valid_users: Array<string>;
@Prop()
inValid_users: Array<string>;
@Prop()
pending_users: Array<string>;
}
export const ResultSchema = SchemaFactory.createForClass(Result)
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