Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
shahriar
instagram-service
Commits
34a84516
Commit
34a84516
authored
Aug 05, 2021
by
soheib
Browse files
add updated schemas
parent
068c60b1
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/app.controller.ts
View file @
34a84516
...
...
@@ -6,11 +6,6 @@ import { GetUserScore } from './dto/get-user-score';
export
class
AppController
{
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
();
...
...
@@ -50,4 +45,11 @@ export class AppController {
async
getResultDb
()
{
return
await
this
.
appService
.
getResultDb
();
}
// depricate code
// @Get('get-comments')
// async getCommentsFromIG() {
// return await this.appService.getComments();
// }
}
src/app.module.ts
View file @
34a84516
import
{
Module
,
OnApplicationBootstrap
}
from
'
@nestjs/common
'
;
import
{
MongooseModule
}
from
'
@nestjs/mongoose
'
;
import
{
Account
Follower
s
Schema
}
from
'
./
account.
follower
s
'
;
import
{
FollowerSchema
}
from
'
./
models/
follower
.schema
'
;
import
{
AppController
}
from
'
./app.controller
'
;
import
{
AppService
}
from
'
./app.service
'
;
import
{
CommentSchema
}
from
'
./comment.schema
'
;
import
{
LottoryResultSchema
}
from
'
./LottoryResult.schema
'
;
import
{
RequestSchema
}
from
'
./request.schema
'
;
import
{
ResultSchema
}
from
'
./result.schema
'
;
import
{
CommentSchema
}
from
'
./models/comment.schema
'
;
import
{
LottoryResultSchema
}
from
'
./models/LottoryResult.schema
'
;
import
{
RequestSchema
}
from
'
./models/request.schema
'
;
import
{
ResultSchema
}
from
'
./models/result.schema
'
;
import
{
PostSchema
}
from
'
./models/post.schema
'
;
@
Module
({
imports
:
[
...
...
@@ -20,7 +21,10 @@ import { ResultSchema } from './result.schema';
{
name
:
'
LottoryResult
'
,
schema
:
LottoryResultSchema
},
]),
MongooseModule
.
forFeature
([
{
name
:
'
AccountFollower
'
,
schema
:
AccountFollowersSchema
},
{
name
:
'
Follower
'
,
schema
:
FollowerSchema
},
]),
MongooseModule
.
forFeature
([
{
name
:
'
Post
'
,
schema
:
PostSchema
},
]),
],
controllers
:
[
AppController
],
...
...
src/app.service.ts
View file @
34a84516
...
...
@@ -6,20 +6,21 @@ import {
}
from
'
@nestjs/common
'
;
import
{
InjectModel
}
from
'
@nestjs/mongoose
'
;
import
{
Model
,
Types
}
from
'
mongoose
'
;
import
{
CommentDocument
}
from
'
./comment.schema
'
;
import
{
CommentDocument
}
from
'
./
models/
comment.schema
'
;
import
{
IFollower
}
from
'
./interface/Ifollower
'
;
import
{
IncomingComment
}
from
'
./interface/IncomingComment
'
;
import
{
RequestDocument
}
from
'
./request.schema
'
;
const
Instagram
=
require
(
'
instagram-web-api
'
);
const
{
username
,
password
}
=
process
.
env
;
import
*
as
_
from
'
lodash
'
;
import
FollowerPrivateData
from
'
./followers_data
'
;
import
FollowerPrivateData
from
'
./
values/
followers_data
'
;
import
{
CleanedComments
,
MentionDocument
}
from
'
./interface/IcleandComment
'
;
import
{
Account
Follower
s
Document
}
from
'
./
account.
follower
s
'
;
import
{
FollowerDocument
}
from
'
./
models/
follower
.schema
'
;
import
{
CommentStatus
,
UserAllMention
}
from
'
./interface/UserAllMentions
'
;
import
{
ResultDocument
}
from
'
./result.schema
'
;
import
{
LottoryResultDocument
}
from
'
./LottoryResult.schema
'
;
import
{
RequestDocument
}
from
'
./models/request.schema
'
;
import
{
ResultDocument
}
from
'
./models/result.schema
'
;
import
{
LottoryResultDocument
}
from
'
./models/LottoryResult.schema
'
;
@
Injectable
()
export
class
AppService
implements
OnApplicationBootstrap
{
...
...
@@ -30,8 +31,8 @@ export class AppService implements OnApplicationBootstrap {
private
requestModel
:
Model
<
RequestDocument
>
,
@
InjectModel
(
'
Comment
'
)
private
commentModel
:
Model
<
CommentDocument
>
,
@
InjectModel
(
'
Account
Follower
'
)
private
followerModel
:
Model
<
Account
Follower
s
Document
>
,
@
InjectModel
(
'
Follower
'
)
private
followerModel
:
Model
<
FollowerDocument
>
,
@
InjectModel
(
'
Result
'
)
private
resultModel
:
Model
<
ResultDocument
>
,
@
InjectModel
(
'
LottoryResult
'
)
...
...
@@ -283,8 +284,8 @@ export class AppService implements OnApplicationBootstrap {
allUserMentions
.
push
(
newMentionData
);
}
else
{
newMentionData
.
mentioned_username
=
foundAccount
.
username
;
newMentionData
.
mentioned_user_id
=
foundAccount
.
user_id
;
newMentionData
.
mentioned_username
=
"
foundAccount.username
"
;
newMentionData
.
mentioned_user_id
=
"
foundAccount.
instagram_
user_id
"
;
newMentionData
.
page_follow_date
=
foundAccount
.
follow_date
;
newMentionData
.
comment_date
=
mentionedUser
.
date
;
...
...
src/LottoryResult.schema.ts
→
src/
models/
LottoryResult.schema.ts
View file @
34a84516
File moved
src/account.
followers
.ts
→
src/
models/
account.
schema
.ts
View file @
34a84516
import
{
Prop
,
Schema
,
SchemaFactory
}
from
'
@nestjs/mongoose
'
;
import
{
Document
,
Types
}
from
'
mongoose
'
;
export
type
Account
Followers
Document
=
Account
Followers
&
Document
;
export
type
AccountDocument
=
Account
&
Document
;
@
Schema
({
timestamps
:
true
})
export
class
Account
Followers
{
export
class
Account
{
@
Prop
()
_id
:
Types
.
ObjectId
;
_id
:
Types
.
ObjectId
@
Prop
()
username
:
string
;
username
:
string
@
Prop
()
user_id
:
string
;
instagram_
user_id
:
string
@
Prop
()
full_name
:
string
;
@
Prop
()
bussines_username
:
string
;
@
Prop
({
type
:
Object
})
follower_obejct
:
Object
;
@
Prop
()
follow_date
:
number
;
full_name
:
string
}
export
const
Account
Followers
Schema
=
SchemaFactory
.
createForClass
(
Account
Followers
);
export
const
AccountSchema
=
SchemaFactory
.
createForClass
(
Account
)
src/comment.schema.ts
→
src/
models/
comment.schema.ts
View file @
34a84516
File moved
src/models/follower.schema.ts
0 → 100644
View file @
34a84516
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
)
src/models/likes.schema.ts
0 → 100644
View file @
34a84516
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
);
src/models/post.schema.ts
0 → 100644
View file @
34a84516
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
)
src/request.schema.ts
→
src/
models/
request.schema.ts
View file @
34a84516
File moved
src/result.schema.ts
→
src/
models/
result.schema.ts
View file @
34a84516
File moved
src/followers.json
→
src/
values/
followers.json
View file @
34a84516
File moved
src/followers_data.ts
→
src/
values/
followers_data.ts
View file @
34a84516
File moved
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment