Commit fbb24753 authored by shahriar's avatar shahriar
Browse files

fix bug

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