fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

ranking: set repo.Rank on read (#481)

The current code sets the repo rank of a `rankedShard`. However we don't read `rankedShard.repos` during evaluation, so setting the repo rank had no effect.

Now we set repo rank when we load the shard.

As a consequence, file matches receive a boost (shard-order) based on their shard's priority.
The effective contribution ranges from `[0, scoresShardRankFactor(=20)]`.

+9 -8
+9
api.go
··· 19 19 "encoding/json" 20 20 "errors" 21 21 "fmt" 22 + "math" 22 23 "reflect" 23 24 "strconv" 24 25 "time" ··· 585 586 r.priority, err = strconv.ParseFloat(v, 64) 586 587 if err != nil { 587 588 r.priority = 0 589 + } 590 + 591 + // Sourcegraph indexserver doesn't set repo.Rank, so we set it here 592 + // based on priority. Setting it on read instead of during indexing 593 + // allows us to avoid a complete reindex. 594 + if r.Rank == 0 && r.priority > 0 { 595 + l := math.Log(float64(r.priority)) 596 + repo.Rank = uint16((1.0 - 1.0/math.Pow(1+l, 0.6)) * 10000) 588 597 } 589 598 } 590 599 return nil
-8
shards/shards.go
··· 971 971 if priority > maxPriority { 972 972 maxPriority = priority 973 973 } 974 - 975 - // No one is reading our searcher yet, so we can mutate it. 976 - // zoekt-sourcegraph-indexserver does not set Rank so at this point we 977 - // treat Priority like star count and set it. 978 - if repo.Rank == 0 && priority > 0 { 979 - l := math.Log(float64(priority)) 980 - repo.Rank = uint16((1.0 - 1.0/math.Pow(1+l, 0.6)) * 10000) 981 - } 982 974 } 983 975 } 984 976