code.gitea.io/gitea@v1.19.3/modules/indexer/issues/db.go (about) 1 // Copyright 2019 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package issues 5 6 import ( 7 "context" 8 9 "code.gitea.io/gitea/models/db" 10 issues_model "code.gitea.io/gitea/models/issues" 11 ) 12 13 // DBIndexer implements Indexer interface to use database's like search 14 type DBIndexer struct{} 15 16 // Init dummy function 17 func (i *DBIndexer) Init() (bool, error) { 18 return false, nil 19 } 20 21 // SetAvailabilityChangeCallback dummy function 22 func (i *DBIndexer) SetAvailabilityChangeCallback(callback func(bool)) { 23 } 24 25 // Ping checks if database is available 26 func (i *DBIndexer) Ping() bool { 27 return db.GetEngine(db.DefaultContext).Ping() != nil 28 } 29 30 // Index dummy function 31 func (i *DBIndexer) Index(issue []*IndexerData) error { 32 return nil 33 } 34 35 // Delete dummy function 36 func (i *DBIndexer) Delete(ids ...int64) error { 37 return nil 38 } 39 40 // Close dummy function 41 func (i *DBIndexer) Close() { 42 } 43 44 // Search dummy function 45 func (i *DBIndexer) Search(ctx context.Context, kw string, repoIDs []int64, limit, start int) (*SearchResult, error) { 46 total, ids, err := issues_model.SearchIssueIDsByKeyword(ctx, kw, repoIDs, limit, start) 47 if err != nil { 48 return nil, err 49 } 50 result := SearchResult{ 51 Total: total, 52 Hits: make([]Match, 0, limit), 53 } 54 for _, id := range ids { 55 result.Hits = append(result.Hits, Match{ 56 ID: id, 57 }) 58 } 59 return &result, nil 60 }