0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 19:23:13 +01:00

fix: use Base36 for all code indexers (#12830)

This commit is contained in:
Jui-Nan Lin 2020-09-14 18:40:07 +08:00 committed by GitHub
parent 53b656582e
commit 6c4e9623cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -37,11 +37,6 @@ import (
const unicodeNormalizeName = "unicodeNormalize" const unicodeNormalizeName = "unicodeNormalize"
const maxBatchSize = 16 const maxBatchSize = 16
// indexerID a bleve-compatible unique identifier for an integer id
func indexerID(id int64) string {
return strconv.FormatInt(id, 36)
}
// numericEqualityQuery a numeric equality query for the given value and field // numericEqualityQuery a numeric equality query for the given value and field
func numericEqualityQuery(value int64, field string) *query.NumericRangeQuery { func numericEqualityQuery(value int64, field string) *query.NumericRangeQuery {
f := float64(value) f := float64(value)

View file

@ -51,12 +51,16 @@ func filenameIndexerID(repoID int64, filename string) string {
return indexerID(repoID) + "_" + filename return indexerID(repoID) + "_" + filename
} }
func indexerID(id int64) string {
return strconv.FormatInt(id, 36)
}
func parseIndexerID(indexerID string) (int64, string) { func parseIndexerID(indexerID string) (int64, string) {
index := strings.IndexByte(indexerID, '_') index := strings.IndexByte(indexerID, '_')
if index == -1 { if index == -1 {
log.Error("Unexpected ID in repo indexer: %s", indexerID) log.Error("Unexpected ID in repo indexer: %s", indexerID)
} }
repoID, _ := strconv.ParseInt(indexerID[:index], 10, 64) repoID, _ := strconv.ParseInt(indexerID[:index], 36, 64)
return repoID, indexerID[index+1:] return repoID, indexerID[index+1:]
} }