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
63d01258
Commit
63d01258
authored
Jul 26, 2021
by
soheib
Browse files
add pointer
parent
627ed44d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app.controller.ts
View file @
63d01258
...
...
@@ -23,8 +23,13 @@ export class AppController {
return
await
this
.
appService
.
calculateUserScore
(
getUserScoreDto
.
username
);
}
@
Get
(
'
result
'
)
async
get
Result
s
()
{
return
await
this
.
appService
.
getResults
()
;
@
Get
(
'
calculate-
result
'
)
async
calculate
Result
()
{
return
await
this
.
appService
.
getResults
()
}
@
Get
(
'
get-results
'
)
async
getResults
()
{
return
await
this
.
appService
.
getFinalResults
();
}
}
src/app.service.ts
View file @
63d01258
...
...
@@ -31,7 +31,7 @@ export class AppService implements OnApplicationBootstrap {
}
async
onApplicationBootstrap
()
{
this
.
client
=
await
this
.
login
(
"
jangomangos
s
"
,
"
kaka
7701
"
)
this
.
client
=
await
this
.
login
(
"
sohe.ib
s
"
,
"
kaka
1374
"
)
}
private
async
login
(
username
,
password
)
{
...
...
@@ -52,8 +52,6 @@ export class AppService implements OnApplicationBootstrap {
}
async
getFollowers
(
account_username
:
string
=
'
azadi.gold
'
)
{
try
{
let
hasNextPage
:
boolean
=
true
let
requestCount
=
0
let
followersCount
=
0
...
...
@@ -70,7 +68,7 @@ export class AppService implements OnApplicationBootstrap {
while
(
hasNextPage
)
{
console
.
log
(
"
seted cursor
"
,
cursor
)
console
.
log
(
"
sending request....
"
)
let
collectedFollower
=
await
this
.
sendFollowerRequest
(
this
.
client
,
account_username
,
cursor
)
let
collectedFollower
=
await
this
.
sendFollowerRequest
(
this
.
client
,
account_username
,
''
)
console
.
log
(
"
request sended. request count:
"
,
requestCount
);
requestCount
++
...
...
@@ -80,7 +78,7 @@ export class AppService implements OnApplicationBootstrap {
hasNextPage
=
collectedFollower
.
hasNextPage
for
await
(
const
follower
of
collectedFollower
.
followers
.
reverse
()
)
{
for
await
(
const
follower
of
collectedFollower
.
followers
)
{
let
check
=
await
this
.
followerModel
.
findOne
({
$and
:
[
{
bussines_username
:
account_username
},
...
...
@@ -100,6 +98,9 @@ export class AppService implements OnApplicationBootstrap {
})
followersCount
+=
1
}
else
{
return
"
already updated
"
}
}
console
.
log
(
"
================next request info==================
"
);
console
.
log
(
"
nextCursor:
"
,
cursor
)
...
...
@@ -108,6 +109,7 @@ export class AppService implements OnApplicationBootstrap {
console
.
log
(
"
================ end of this Request Proccess ==================
"
);
}
return
{
status
:
"
successfull
"
,
totalAdded
:
followersCount
...
...
@@ -147,7 +149,7 @@ export class AppService implements OnApplicationBootstrap {
await
this
.
requestModel
.
create
({
_id
:
new
Types
.
ObjectId
(),
cursor
:
cursor
,
type
:
"
comment
"
,
post_short_code
:
postShortCode
})
hasNextPage
=
collectedComments
.
hasNextPage
for
await
(
const
comment
of
collectedComments
.
comments
.
reverse
()
)
{
for
await
(
const
comment
of
collectedComments
.
comments
)
{
let
check
=
await
this
.
commentModel
.
findOne
({
comment_id
:
comment
.
comment_id
})
...
...
@@ -163,6 +165,9 @@ export class AppService implements OnApplicationBootstrap {
})
commentCount
+=
1
}
else
{
return
"
already updated
"
}
}
console
.
log
(
"
================nex request info==================
"
);
...
...
@@ -265,7 +270,7 @@ export class AppService implements OnApplicationBootstrap {
}
return
{
followers
:
Infollowers
,
cursor
:
pointer
,
cursor
:
''
,
hasNextPage
:
followers
.
page_info
.
has_next_page
}
}
...
...
@@ -414,7 +419,9 @@ export class AppService implements OnApplicationBootstrap {
invalid_mentions
,
pending_mentions
,
score
:
valid_mentions
+
1
,
valid_users
,
inValid_users
,
pending_users
valid_users
:
valid_users
,
inValid_users
:
inValid_users
,
pending_users
:
pending_users
})
}
else
{
await
this
.
resultModel
.
updateOne
(
foundUser
.
_id
,
{
...
...
@@ -423,7 +430,9 @@ export class AppService implements OnApplicationBootstrap {
invalid_mentions
,
pending_mentions
,
score
:
valid_mentions
+
1
,
valid_users
,
inValid_users
,
pending_users
valid_users
:
valid_users
,
inValid_users
:
inValid_users
,
pending_users
:
pending_users
})
}
}
...
...
@@ -473,6 +482,10 @@ export class AppService implements OnApplicationBootstrap {
return
follower_objectResult
}
async
getFinalResults
(){
return
await
this
.
resultModel
.
find
()
}
}
src/followers_data.ts
View file @
63d01258
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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