Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
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-group
Commits
1ccc8c2f
You need to sign in or sign up before continuing.
Commit
1ccc8c2f
authored
Aug 27, 2023
by
JiebinHu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:榜单漏了日期
parent
e8e15102
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
group_power_star.go
_const/redis_key/groupPower_k/group_power_star.go
+4
-3
group_power_star.go
domain/cache/groupPower_c/group_power_star.go
+25
-2
No files found.
_const/redis_key/groupPower_k/group_power_star.go
View file @
1ccc8c2f
...
@@ -8,9 +8,10 @@ import (
...
@@ -8,9 +8,10 @@ import (
// 家族之星榜单
// 家族之星榜单
// type: 1:送礼 2:活跃 3:收礼
// type: 1:送礼 2:活跃 3:收礼
const
GroupPowerStarPrefix
=
"groupPowerStar:${type}:${period}:${groupPowerId}"
// zset member:userId score:分数
// date:天/周/月的开始时间
const
GroupPowerStarPrefix
=
"groupPowerStar:${type}:${period}:${groupPowerId}:${date}"
// zset member:userId score:分数
func
GetGroupPowerStarRankKey
(
_type
groupPower_e
.
GroupPowerStarType
,
period
string
,
groupPowerId
uint64
)
string
{
func
GetGroupPowerStarRankKey
(
_type
groupPower_e
.
GroupPowerStarType
,
period
string
,
groupPowerId
uint64
,
date
string
)
string
{
return
redis_key
.
ReplaceKey
(
GroupPowerStarPrefix
,
return
redis_key
.
ReplaceKey
(
GroupPowerStarPrefix
,
fmt
.
Sprintf
(
"%d"
,
_type
),
period
,
fmt
.
Sprintf
(
"%d"
,
groupPowerId
))
fmt
.
Sprintf
(
"%d"
,
_type
),
period
,
fmt
.
Sprintf
(
"%d"
,
groupPowerId
)
,
date
)
}
}
domain/cache/groupPower_c/group_power_star.go
View file @
1ccc8c2f
...
@@ -5,6 +5,8 @@ import (
...
@@ -5,6 +5,8 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"github.com/go-redis/redis/v8"
"github.com/go-redis/redis/v8"
"github.com/jinzhu/now"
"github.com/pkg/errors"
"github.com/spf13/cast"
"github.com/spf13/cast"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/_const/redis_key/groupPower_k"
"hilo-group/_const/redis_key/groupPower_k"
...
@@ -28,7 +30,16 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
...
@@ -28,7 +30,16 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
"month"
:
time
.
Hour
*
24
*
7
*
30
*
2
,
"month"
:
time
.
Hour
*
24
*
7
*
30
*
2
,
}
}
for
_
,
period
:=
range
[]
string
{
"day"
,
"week"
,
"month"
}
{
for
_
,
period
:=
range
[]
string
{
"day"
,
"week"
,
"month"
}
{
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
)
date
:=
""
switch
period
{
case
"day"
:
date
=
time
.
Now
()
.
Format
(
"2006-01-02"
)
case
"week"
:
date
=
now
.
BeginningOfWeek
()
.
Format
(
"2006-01-02"
)
case
"month"
:
date
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
)
}
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
,
date
)
model
.
RedisCluster
.
ZIncrBy
(
model
,
key
,
float64
(
score
),
fmt
.
Sprintf
(
"%d"
,
userId
))
model
.
RedisCluster
.
ZIncrBy
(
model
,
key
,
float64
(
score
),
fmt
.
Sprintf
(
"%d"
,
userId
))
model
.
RedisCluster
.
Expire
(
model
,
key
,
ttl
[
period
])
model
.
RedisCluster
.
Expire
(
model
,
key
,
ttl
[
period
])
}
}
...
@@ -38,7 +49,19 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
...
@@ -38,7 +49,19 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
// 获取家族之星排行
// 获取家族之星排行
func
GetGroupPowerStarRankPeriod
(
model
*
domain
.
Model
,
period
string
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
)
([]
*
GroupPowerStarRank
,
error
)
{
func
GetGroupPowerStarRankPeriod
(
model
*
domain
.
Model
,
period
string
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
)
([]
*
GroupPowerStarRank
,
error
)
{
var
res
[]
*
GroupPowerStarRank
var
res
[]
*
GroupPowerStarRank
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
)
date
:=
""
switch
period
{
case
"day"
:
date
=
time
.
Now
()
.
Format
(
"2006-01-02"
)
case
"week"
:
date
=
now
.
BeginningOfWeek
()
.
Format
(
"2006-01-02"
)
case
"month"
:
date
=
now
.
BeginningOfMonth
()
.
Format
(
"2006-01-02"
)
}
if
len
(
date
)
<=
0
{
return
res
,
errors
.
New
(
"illegal date"
)
}
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
,
date
)
rows
,
err
:=
model
.
RedisCluster
.
ZRevRangeByScoreWithScores
(
model
,
key
,
&
redis
.
ZRangeBy
{
rows
,
err
:=
model
.
RedisCluster
.
ZRevRangeByScoreWithScores
(
model
,
key
,
&
redis
.
ZRangeBy
{
Min
:
"-inf"
,
Min
:
"-inf"
,
Max
:
"+inf"
,
Max
:
"+inf"
,
...
...
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