Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Revive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Ygopro Arena Revive
Commits
3917fb3c
Commit
3917fb3c
authored
Feb 19, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
random vote use find
parent
71091bba
Pipeline
#2457
passed with stages
in 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
src/app.service.ts
src/app.service.ts
+16
-9
No files found.
src/app.service.ts
View file @
3917fb3c
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
InjectConnection
,
InjectEntityManager
}
from
'
@nestjs/typeorm
'
;
import
{
InjectConnection
,
InjectEntityManager
}
from
'
@nestjs/typeorm
'
;
import
{
Connection
,
EntityManager
,
LessThan
,
MoreThanOrEqual
}
from
'
typeorm
'
;
import
{
Connection
,
EntityManager
,
LessThan
,
LessThanOrEqual
,
MoreThanOrEqual
,
}
from
'
typeorm
'
;
import
{
UserInfo
}
from
'
./entities/mycard/UserInfo
'
;
import
{
UserInfo
}
from
'
./entities/mycard/UserInfo
'
;
import
Filter
from
'
bad-words-chinese
'
;
import
Filter
from
'
bad-words-chinese
'
;
import
{
ChineseDirtyWords
}
from
'
./dirtyWordsChinese
'
;
import
{
ChineseDirtyWords
}
from
'
./dirtyWordsChinese
'
;
...
@@ -1038,16 +1044,17 @@ export class AppService {
...
@@ -1038,16 +1044,17 @@ export class AppService {
async
getRandomVote
(
userid
:
string
)
{
async
getRandomVote
(
userid
:
string
)
{
const
now
=
moment
().
toDate
();
const
now
=
moment
().
toDate
();
const
allVotes
=
await
this
.
mcdb
const
allVotes
=
await
this
.
mcdb
.
getRepository
(
Votes
).
find
({
.
getRepository
(
Votes
)
status
:
true
,
.
createQueryBuilder
(
'
vote
'
)
startTime
:
LessThanOrEqual
(
now
),
.
where
(
"
vote.status = 't'
"
)
endTime
:
MoreThanOrEqual
(
now
),
.
andWhere
(
'
vote.start_time <= :now
'
,
{
now
})
});
.
andWhere
(
'
vote.end_time >= :now
'
,
{
now
})
.
getMany
();
const
votedIds
=
(
const
votedIds
=
(
await
this
.
mcdb
.
getRepository
(
VoteResult
).
find
({
await
this
.
mcdb
.
getRepository
(
VoteResult
).
find
({
userid
,
select
:
[
'
voteId
'
],
where
:
{
userid
,
},
})
})
).
map
((
voteResult
)
=>
parseInt
(
voteResult
.
voteId
));
).
map
((
voteResult
)
=>
parseInt
(
voteResult
.
voteId
));
const
validVotes
=
allVotes
.
filter
((
vote
)
=>
!
votedIds
.
includes
(
vote
.
id
));
const
validVotes
=
allVotes
.
filter
((
vote
)
=>
!
votedIds
.
includes
(
vote
.
id
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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