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
7ca23a51
Commit
7ca23a51
authored
Jul 27, 2021
by
velayat
Browse files
working on comments list
parent
63d01258
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Dockerfile
0 → 100644
View file @
7ca23a51
FROM
node:14-alpine
AS
development
WORKDIR
/usr/src/app
COPY
package.json ./
RUN
npm
install
glob rimraf
RUN
npm
install
COPY
. .
RUN
npm run build
FROM
node:14-alpine
as
production
ARG
NODE_ENV=production
ENV
NODE_ENV=${NODE_ENV}
WORKDIR
/usr/src/app
COPY
package.json ./
RUN
npm
install
COPY
. .
COPY
--from=development /usr/src/app/dist ./dist
CMD
["node", "dist/main"]
docker-compose.yml
0 → 100644
View file @
7ca23a51
version
:
'
3.8'
services
:
prod
:
container_name
:
instagram-lottery
image
:
instagram-lottery-prod:1.2.0
build
:
context
:
.
target
:
production
dockerfile
:
./Dockerfile
command
:
npm run start:prod
ports
:
-
3000:3000
# - 9229:9229
networks
:
-
nestjs-network
volumes
:
-
.:/usr/src/app
-
/usr/src/app/node_modules
restart
:
unless-stopped
networks
:
nestjs-network
:
package-lock.json
View file @
7ca23a51
This diff is collapsed.
Click to expand it.
src/app.service.ts
View file @
7ca23a51
...
...
@@ -127,21 +127,21 @@ export class AppService implements OnApplicationBootstrap {
let
requestCount
=
0
let
commentCount
=
0
let
cursor
:
string
=
''
let
reqList
=
await
this
.
requestModel
.
find
({
$and
:
[{
type
:
"
comment
"
},
{
post_short_code
:
postShortCode
}]
}).
sort
({
createdAt
:
-
1
})
//
let reqList = await this.requestModel.find({ $and: [{ type: "comment" }, { post_short_code: postShortCode }] }).sort({ createdAt: -1 })
console
.
log
(
"
Request History:
"
,
reqList
.
length
)
//
console.log("Request History:", reqList.length)
if
(
reqList
.
length
!=
0
)
{
//
if (reqList.length != 0) {
//let nextCursor = await this.getCommentsNextCursor(client, reqList[0].cursor, postShortCode)
//console.log("=======nextCursor=======", nextCursor);
cursor
=
reqList
[
0
].
cursor
}
//
cursor = reqList[0].cursor
//
}
while
(
hasNextPage
)
{
console
.
log
(
"
seted cursor
"
,
cursor
)
//
console.log("seted cursor", cursor)
console
.
log
(
"
sending request....
"
)
let
collectedComments
=
await
this
.
sendCommentRequest
(
this
.
client
,
postShortCode
,
cursor
)
let
collectedComments
=
await
this
.
sendCommentRequest
(
this
.
client
,
postShortCode
,
''
)
console
.
log
(
"
request sended. request count:
"
,
requestCount
);
requestCount
++
...
...
@@ -205,8 +205,7 @@ export class AppService implements OnApplicationBootstrap {
try
{
let
comments
:
IncomingComment
[]
=
new
Array
<
IncomingComment
>
()
await
this
.
delay
(
_
.
random
(
2000
,
10000
))
let
incomingComments
=
await
client
.
getMediaComments
({
shortcode
:
postShortCode
,
first
:
"
49
"
,
after
:
cursor
})
let
incomingComments
=
await
client
.
getMediaComments
({
shortcode
:
postShortCode
,
first
:
"
49
"
,
after
:
''
})
console
.
log
(
"
=============incoming comments=============
"
,
incomingComments
);
...
...
@@ -230,9 +229,11 @@ export class AppService implements OnApplicationBootstrap {
}
catch
(
e
)
{
console
.
log
(
`Pointer is not array!, dont need to be converted!`
);
}
await
this
.
delay
(
_
.
random
(
2000
,
10000
))
return
{
comments
,
cursor
:
pointer
,
cursor
:
''
,
hasNextPage
:
incomingComments
.
page_info
.
has_next_page
}
}
...
...
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