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
11b7f235
Commit
11b7f235
authored
Aug 11, 2021
by
soheib
Browse files
add user change status to online
parent
ce49fc38
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/instagram/models/user.schema.ts
View file @
11b7f235
...
...
@@ -24,6 +24,9 @@ export class User {
@
Prop
({
enum
:
AccountType
})
type
:
string
@
Prop
()
mobile
:
string
}
export
const
UserSchema
=
SchemaFactory
.
createForClass
(
User
)
\ No newline at end of file
src/lottery/dto/change-status-dto.ts
0 → 100644
View file @
11b7f235
export
class
ChangeStatusDto
{
mobile
:
string
username
:
string
}
\ No newline at end of file
src/lottery/lottery.controller.ts
View file @
11b7f235
import
{
Body
,
Query
,
Controller
,
Get
,
Post
}
from
'
@nestjs/common
'
;
import
{
CalculateScoreDto
}
from
'
./dto/calculate-score-dto
'
import
{
ChangeStatusDto
}
from
'
./dto/change-status-dto
'
import
{
WeeklySearchDto
}
from
'
./dto/weekly-search-dto
'
import
{
LotteryService
}
from
'
./lottery.service
'
;
...
...
@@ -16,7 +17,7 @@ export class LotteryController {
}
@
Post
(
'
weekly/calculate-score
'
)
async
addResultsToDb
(
calculateScoreDto
:
CalculateScoreDto
)
{
async
addResultsToDb
(
@
Body
()
calculateScoreDto
:
CalculateScoreDto
)
{
return
await
this
.
lotteryService
.
addResultsToDB
(
calculateScoreDto
.
profile_username
,
calculateScoreDto
.
post_array
)
}
...
...
@@ -25,4 +26,9 @@ export class LotteryController {
async
getResultDb
()
{
return
await
this
.
lotteryService
.
getResultDb
()
}
@
Post
(
'
weekly/change-status
'
)
async
changeStatus
(@
Body
()
changeStatusDto
:
ChangeStatusDto
)
{
return
await
this
.
lotteryService
.
changeStatus
(
changeStatusDto
)
}
}
src/lottery/lottery.service.ts
View file @
11b7f235
import
{
HttpException
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
InjectModel
}
from
'
@nestjs/mongoose
'
;
import
{
Model
}
from
'
mongoose
'
;
import
{
of
}
from
'
rxjs
'
import
{
CommentDocument
}
from
'
src/instagram/models/comment.schema
'
;
import
{
FollowerDocument
}
from
'
src/instagram/models/follower.schema
'
;
import
{
LikeDocument
}
from
'
src/instagram/models/like.schema
'
;
import
{
LottoryResultDocument
}
from
'
src/instagram/models/LottoryResult.schema
'
import
{
UserDocument
}
from
'
src/instagram/models/user.schema
'
;
import
addToStoryData
from
'
../instagram/values/add-to-story-data
'
import
{
ChangeStatusDto
}
from
'
./dto/change-status-dto
'
import
{
ScoreService
}
from
'
./score.service
'
;
...
...
@@ -22,7 +25,7 @@ export class LotteryService {
@
InjectModel
(
'
Comment
'
)
private
commentModel
:
Model
<
CommentDocument
>
,
@
InjectModel
(
'
LottryResult
'
)
private
lotteryResultModel
:
Model
<
Commen
tDocument
>
private
lotteryResultModel
:
Model
<
LottoryResul
tDocument
>
)
{
}
async
getUserScore
(
username
:
string
,
profileUsername
:
string
,
postArray
:
string
[])
{
...
...
@@ -76,7 +79,20 @@ export class LotteryService {
async
getResultDb
()
{
return
await
this
.
lotteryResultModel
.
find
()
.
select
({
username
:
1
,
index
:
1
});
.
select
({
username
:
1
,
index
:
1
,
status
:
1
});
}
async
changeStatus
(
changeStatus
:
ChangeStatusDto
){
let
foundLottryResults
=
await
this
.
lotteryResultModel
.
find
({
username
:
changeStatus
.
username
})
for
await
(
const
result
of
foundLottryResults
)
{
result
.
status
=
"
online
"
await
result
.
save
()
}
await
this
.
userModel
.
findOneAndUpdate
({
username
:
changeStatus
.
username
},{
mobile
:
changeStatus
.
mobile
})
return
{
message
:
"
status changed to online successfully
"
}
}
}
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