Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
9027c4fd
Commit
9027c4fd
authored
Aug 24, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
cee5287b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
Makefile
script/Makefile
+2
-0
race_ksa_rank.go
script/race_ksa_rank.go
+60
-0
No files found.
script/Makefile
View file @
9027c4fd
...
@@ -24,4 +24,6 @@ fruit_day_award:
...
@@ -24,4 +24,6 @@ fruit_day_award:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
fruit_day_award fruit_day_award.go
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
fruit_day_award fruit_day_award.go
race_day_award
:
race_day_award
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
race_day_award race_day_award.go
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
race_day_award race_day_award.go
race_ksa_rank
:
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64 go build
-o
race_ksa_rank race_ksa_rank.go
script/race_ksa_rank.go
0 → 100644
View file @
9027c4fd
package
main
import
(
"git.hilo.cn/hilo-common/script/mysql"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type
RaceDayRankKsa
struct
{
Period
string
UserId
uint64
Stake
uint64
Award
uint64
}
type
TmpRank
struct
{
D
string
UserId
uint64
Stake
uint64
Award
uint64
}
func
main
()
{
stakeSql
:=
`SELECT DATE_FORMAT(created_time,"%Y-%m-%d") d,user_id,SUM(stake) stake FROM game_race_stake GROUP BY d,user_id ;`
var
stakeRanks
[]
TmpRank
if
err
:=
mysql
.
ProdWriteDB
.
Raw
(
stakeSql
)
.
Scan
(
&
stakeRanks
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
v
:=
range
stakeRanks
{
if
err
:=
mysql
.
ProdWriteDB
.
Model
(
RaceDayRankKsa
{})
.
Clauses
(
clause
.
OnConflict
{
Columns
:
[]
clause
.
Column
{{
Name
:
"period"
},
{
Name
:
"user_id"
}},
DoUpdates
:
clause
.
Assignments
(
map
[
string
]
interface
{}{
"stake"
:
gorm
.
Expr
(
"stake+ ?"
,
v
.
Stake
),
}),
})
.
Create
(
&
RaceDayRankKsa
{
Period
:
v
.
D
,
UserId
:
v
.
UserId
,
Stake
:
v
.
Stake
,
})
.
Error
;
err
!=
nil
{
panic
(
err
)
}
}
awardSql
:=
`SELECT DATE_FORMAT(created_time,"%Y-%m-%d") d,user_id,SUM(award) award FROM game_race_player GROUP BY d,user_id;`
var
awardRanks
[]
TmpRank
if
err
:=
mysql
.
ProdWriteDB
.
Raw
(
awardSql
)
.
Scan
(
&
awardRanks
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
for
_
,
v
:=
range
awardRanks
{
if
err
:=
mysql
.
ProdWriteDB
.
Model
(
RaceDayRankKsa
{})
.
Clauses
(
clause
.
OnConflict
{
Columns
:
[]
clause
.
Column
{{
Name
:
"period"
},
{
Name
:
"user_id"
}},
DoUpdates
:
clause
.
Assignments
(
map
[
string
]
interface
{}{
"award"
:
gorm
.
Expr
(
"award+ ?"
,
v
.
Award
),
}),
})
.
Create
(
&
RaceDayRankKsa
{
Period
:
v
.
D
,
UserId
:
v
.
UserId
,
Award
:
v
.
Award
,
})
.
Error
;
err
!=
nil
{
panic
(
err
)
}
}
}
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