Commit 34a84516 authored by soheib's avatar soheib
Browse files

add updated schemas

parent 068c60b1
...@@ -6,11 +6,6 @@ import { GetUserScore } from './dto/get-user-score'; ...@@ -6,11 +6,6 @@ import { GetUserScore } from './dto/get-user-score';
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-followers') @Get('get-followers')
async getFollowers() { async getFollowers() {
return await this.appService.getFollowers(); return await this.appService.getFollowers();
...@@ -50,4 +45,11 @@ export class AppController { ...@@ -50,4 +45,11 @@ export class AppController {
async getResultDb() { async getResultDb() {
return await this.appService.getResultDb(); return await this.appService.getResultDb();
} }
// depricate code
// @Get('get-comments')
// async getCommentsFromIG() {
// return await this.appService.getComments();
// }
} }
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 { FollowerSchema } from './models/follower.schema';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { CommentSchema } from './comment.schema'; import { CommentSchema } from './models/comment.schema';
import { LottoryResultSchema } from './LottoryResult.schema'; import { LottoryResultSchema } from './models/LottoryResult.schema';
import { RequestSchema } from './request.schema'; import { RequestSchema } from './models/request.schema';
import { ResultSchema } from './result.schema'; import { ResultSchema } from './models/result.schema';
import { PostSchema } from './models/post.schema';
@Module({ @Module({
imports: [ imports: [
...@@ -20,7 +21,10 @@ import { ResultSchema } from './result.schema'; ...@@ -20,7 +21,10 @@ import { ResultSchema } from './result.schema';
{ name: 'LottoryResult', schema: LottoryResultSchema }, { name: 'LottoryResult', schema: LottoryResultSchema },
]), ]),
MongooseModule.forFeature([ MongooseModule.forFeature([
{ name: 'AccountFollower', schema: AccountFollowersSchema }, { name: 'Follower', schema: FollowerSchema },
]),
MongooseModule.forFeature([
{ name: 'Post', schema: PostSchema },
]), ]),
], ],
controllers: [AppController], controllers: [AppController],
......
...@@ -6,20 +6,21 @@ import { ...@@ -6,20 +6,21 @@ import {
} from '@nestjs/common'; } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
import { Model, Types } from 'mongoose'; import { Model, Types } from 'mongoose';
import { CommentDocument } from './comment.schema'; import { CommentDocument } from './models/comment.schema';
import { IFollower } from './interface/Ifollower'; import { IFollower } from './interface/Ifollower';
import { IncomingComment } from './interface/IncomingComment'; import { IncomingComment } from './interface/IncomingComment';
import { RequestDocument } from './request.schema';
const Instagram = require('instagram-web-api'); const Instagram = require('instagram-web-api');
const { username, password } = process.env; const { username, password } = process.env;
import * as _ from 'lodash'; import * as _ from 'lodash';
import FollowerPrivateData from './followers_data'; import FollowerPrivateData from './values/followers_data';
import { CleanedComments, MentionDocument } from './interface/IcleandComment'; import { CleanedComments, MentionDocument } from './interface/IcleandComment';
import { AccountFollowersDocument } from './account.followers'; import { FollowerDocument } from './models/follower.schema';
import { CommentStatus, UserAllMention } from './interface/UserAllMentions'; import { CommentStatus, UserAllMention } from './interface/UserAllMentions';
import { ResultDocument } from './result.schema'; import { RequestDocument } from './models/request.schema';
import { LottoryResultDocument } from './LottoryResult.schema'; import { ResultDocument } from './models/result.schema';
import { LottoryResultDocument } from './models/LottoryResult.schema';
@Injectable() @Injectable()
export class AppService implements OnApplicationBootstrap { export class AppService implements OnApplicationBootstrap {
...@@ -30,8 +31,8 @@ export class AppService implements OnApplicationBootstrap { ...@@ -30,8 +31,8 @@ export class AppService implements OnApplicationBootstrap {
private requestModel: Model<RequestDocument>, private requestModel: Model<RequestDocument>,
@InjectModel('Comment') @InjectModel('Comment')
private commentModel: Model<CommentDocument>, private commentModel: Model<CommentDocument>,
@InjectModel('AccountFollower') @InjectModel('Follower')
private followerModel: Model<AccountFollowersDocument>, private followerModel: Model<FollowerDocument>,
@InjectModel('Result') @InjectModel('Result')
private resultModel: Model<ResultDocument>, private resultModel: Model<ResultDocument>,
@InjectModel('LottoryResult') @InjectModel('LottoryResult')
...@@ -283,8 +284,8 @@ export class AppService implements OnApplicationBootstrap { ...@@ -283,8 +284,8 @@ export class AppService implements OnApplicationBootstrap {
allUserMentions.push(newMentionData); allUserMentions.push(newMentionData);
} else { } else {
newMentionData.mentioned_username = foundAccount.username; newMentionData.mentioned_username = "foundAccount.username";
newMentionData.mentioned_user_id = foundAccount.user_id; newMentionData.mentioned_user_id = "foundAccount.instagram_user_id";
newMentionData.page_follow_date = foundAccount.follow_date; newMentionData.page_follow_date = foundAccount.follow_date;
newMentionData.comment_date = mentionedUser.date; newMentionData.comment_date = mentionedUser.date;
......
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 AccountDocument = Account & Document;
@Schema({ timestamps: true }) @Schema({ timestamps: true })
export class AccountFollowers { export class Account {
@Prop() @Prop()
_id: Types.ObjectId; _id: Types.ObjectId
@Prop() @Prop()
username: string; username: string
@Prop() @Prop()
user_id: string; instagram_user_id: string
@Prop() @Prop()
full_name: string; full_name: string
@Prop()
bussines_username: string;
@Prop({ type: Object })
follower_obejct: Object;
@Prop()
follow_date: number;
} }
export const AccountFollowersSchema = export const AccountSchema =
SchemaFactory.createForClass(AccountFollowers); SchemaFactory.createForClass(Account)
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type FollowerDocument = Follower & Document;
@Schema({ timestamps: true })
export class Follower {
@Prop()
_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Account' })
user_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Account' })
account_id: Types.ObjectId
@Prop({ type: Object })
follower_obejct: Object
@Prop()
follow_date: number
// @Prop()
// likes_count: number
// @Prop()
// comment_count: number
}
export const FollowerSchema =
SchemaFactory.createForClass(Follower)
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type LikeDocument = Like & Document;
@Schema({ timestamps: true })
export class Like {
@Prop()
_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Follower' })
follower_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Post' })
post_id: string
@Prop()
date: number
}
export const LikeSchema = SchemaFactory.createForClass(Like);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type PostDocument = Post & Document;
@Schema({ timestamps: true })
export class Post {
@Prop()
_id: Types.ObjectId
@Prop()
url: string
@Prop()
instagram_id: string
}
export const PostSchema =
SchemaFactory.createForClass(Post)
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