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
866f7637
Commit
866f7637
authored
Jul 27, 2021
by
soheib
Browse files
add search api
parent
81112171
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app.controller.ts
View file @
866f7637
...
...
@@ -32,4 +32,9 @@ export class AppController {
async
getResults
()
{
return
await
this
.
appService
.
getFinalResults
();
}
@
Post
(
'
search
'
)
async
getUserResults
(@
Body
(
'
username
'
)
username
:
string
)
{
return
await
this
.
appService
.
getUserResult
(
username
);
}
}
src/app.service.ts
View file @
866f7637
...
...
@@ -132,9 +132,9 @@ export class AppService implements OnApplicationBootstrap {
// console.log("Request History:", reqList.length)
// if (reqList.length != 0) {
//let nextCursor = await this.getCommentsNextCursor(client, reqList[0].cursor, postShortCode)
//console.log("=======nextCursor=======", nextCursor);
// cursor = reqList[0].cursor
//let nextCursor = await this.getCommentsNextCursor(client, reqList[0].cursor, postShortCode)
//console.log("=======nextCursor=======", nextCursor);
// cursor = reqList[0].cursor
// }
...
...
@@ -439,6 +439,8 @@ export class AppService implements OnApplicationBootstrap {
return
"
records updated successfully
"
}
async
checkUserMentionedBefore
(
username
,
comment_date
)
{
let
foundCommentsWithThisMention
=
await
this
.
commentModel
.
find
({
text
:
new
RegExp
(
`@
${
username
}
`
)
...
...
@@ -524,6 +526,35 @@ export class AppService implements OnApplicationBootstrap {
last_update
:
date
}
}
async
getUserResult
(
username
:
string
)
{
let
userRes
=
await
this
.
resultModel
.
findOne
({
username
})
let
response
:
ResultResponse
=
new
ResultResponse
()
response
.
users
=
new
Array
<
any
>
()
userRes
.
pending_users
.
forEach
(
user
=>
{
response
.
users
.
push
({
userId
:
user
,
status
:
CommentStatus
.
notFollower
})
})
userRes
.
inValid_users
.
forEach
(
user
=>
{
response
.
users
.
push
({
userId
:
user
,
status
:
CommentStatus
.
inValid
})
})
userRes
.
valid_users
.
forEach
(
user
=>
{
response
.
users
.
push
({
userId
:
user
,
status
:
CommentStatus
.
isValid
})
})
response
.
username
=
userRes
.
username
,
response
.
valid_mentions
=
userRes
.
valid_mentions
,
response
.
invalid_mentions
=
userRes
.
invalid_mentions
,
response
.
pending_mentions
=
userRes
.
pending_mentions
,
response
.
score
=
userRes
.
score
return
{
response
}
}
}
export
class
ResultResponse
{
...
...
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