mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-01-22 12:21:11 -05:00
Add handling for nil TosHighlights in ComputeScore function
This commit is contained in:
parent
68a31df2e8
commit
c91f0b4613
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"pluja.dev/kycnot.me/database"
|
"pluja.dev/kycnot.me/database"
|
||||||
"pluja.dev/kycnot.me/ent"
|
"pluja.dev/kycnot.me/ent"
|
||||||
|
"pluja.dev/kycnot.me/ent/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ComputeScore(s *ent.Service) int {
|
func ComputeScore(s *ent.Service) int {
|
||||||
@ -41,6 +42,9 @@ func ComputeScore(s *ent.Service) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tos Highlights Penalty
|
// Tos Highlights Penalty
|
||||||
|
if s.TosHighlights == nil {
|
||||||
|
s.TosHighlights = &[]schema.TosHighlight{}
|
||||||
|
}
|
||||||
nTosH := len(*s.TosHighlights)
|
nTosH := len(*s.TosHighlights)
|
||||||
nTosPenalty := float64(nTosH) * bonusMedium // Each 2 TOS highlights, decrease the score by 1
|
nTosPenalty := float64(nTosH) * bonusMedium // Each 2 TOS highlights, decrease the score by 1
|
||||||
if nTosPenalty > maxTosPenalty {
|
if nTosPenalty > maxTosPenalty {
|
||||||
|
Loading…
Reference in New Issue
Block a user