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
bded2cd7
Commit
bded2cd7
authored
Aug 15, 2021
by
soheib
Browse files
fix lottrey result bug when start from first
parent
027de527
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lottery/lottery.service.ts
View file @
bded2cd7
...
...
@@ -53,10 +53,12 @@ export class LotteryService {
foundUser_idsList
.
push
(
user_id
)
}
})
let
user_index
=
0
for
await
(
const
user_id
of
foundUser_idsList
)
{
let
userScore
=
await
this
.
scoreService
.
calculateUserScore
(
user_id
,
profileUsername
,
postArray
)
for
(
let
u
=
0
;
u
<
userScore
;
u
++
)
{
console
.
log
();
let
foundIndex
=
await
this
.
lotteryResultModel
.
findOne
({
$and
:
[
{
...
...
@@ -68,14 +70,15 @@ export class LotteryService {
if
(
!
foundIndex
)
{
await
this
.
lotteryResultModel
.
create
({
_id
:
new
Types
.
ObjectId
(),
index
:
`
${
u
ser_index
}
`
,
index
:
`
${
u
}
`
,
user_id
:
user_id
,
status
:
'
valid
'
,
chance
:
await
this
.
codeGenerator
()
})
}
}
user_index
++
}
return
'
successfull
'
}
...
...
@@ -83,9 +86,13 @@ export class LotteryService {
let
lastIndex
=
await
this
.
lotteryResultModel
.
find
().
sort
({
createdAt
:
-
1
})
if
(
lastIndex
[
0
])
{
let
temp
=
lastIndex
[
0
].
chance
let
code
=
Number
(
temp
.
split
(
'
LT_
'
)[
1
])
return
`LT_
${
code
++
}
`
let
lastChanceIndex
=
lastIndex
[
0
].
chance
console
.
log
(
'
last chance
'
,
lastChanceIndex
);
let
code
=
lastChanceIndex
.
split
(
'
LT_
'
)[
1
]
console
.
log
(
'
code
'
,
code
);
let
res
=
`LT_
${(
Number
(
code
)
+
1
)}
`
console
.
log
(
'
res
'
,
res
);
return
res
}
else
{
return
`LT_
${
1000
}
`
...
...
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