Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0bc9072d
authored
Apr 04, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: GetRandomSatisfiedChannel
parent
7b484beb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
common/constants.go
+1
-1
model/ability.go
+1
-1
No files found.
common/constants.go
View file @
0bc9072d
...
...
@@ -111,7 +111,7 @@ var IsMasterNode = os.Getenv("NODE_TYPE") != "slave"
var
requestInterval
,
_
=
strconv
.
Atoi
(
os
.
Getenv
(
"POLLING_INTERVAL"
))
var
RequestInterval
=
time
.
Duration
(
requestInterval
)
*
time
.
Second
var
SyncFrequency
=
GetOrDefault
(
"SYNC_FREQUENCY"
,
10
*
60
)
// unit is second
var
SyncFrequency
=
GetOrDefault
(
"SYNC_FREQUENCY"
,
60
)
// unit is second
var
BatchUpdateEnabled
=
false
var
BatchUpdateInterval
=
GetOrDefault
(
"BATCH_UPDATE_INTERVAL"
,
5
)
...
...
model/ability.go
View file @
0bc9072d
...
...
@@ -57,7 +57,7 @@ func GetRandomSatisfiedChannel(group string, model string) (*Channel, error) {
// Randomly choose one
weight
:=
common
.
GetRandomInt
(
int
(
weightSum
))
for
_
,
ability_
:=
range
abilities
{
weight
-=
int
(
ability_
.
Weight
)
weight
-=
int
(
ability_
.
Weight
)
+
10
//log.Printf("weight: %d, ability weight: %d", weight, *ability_.Weight)
if
weight
<=
0
{
channel
.
Id
=
ability_
.
ChannelId
...
...
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