|
4 | 4 |
|
5 | 5 | package issues |
6 | 6 |
|
7 | | -import "code.gitea.io/gitea/models" |
| 7 | +import ( |
| 8 | + "code.gitea.io/gitea/models" |
| 9 | + "code.gitea.io/gitea/models/db" |
| 10 | +) |
8 | 11 |
|
9 | 12 | // DBIndexer implements Indexer interface to use database's like search |
10 | 13 | type DBIndexer struct{} |
11 | 14 |
|
12 | 15 | // Init dummy function |
13 | | -func (db *DBIndexer) Init() (bool, error) { |
| 16 | +func (i *DBIndexer) Init() (bool, error) { |
14 | 17 | return false, nil |
15 | 18 | } |
16 | 19 |
|
17 | 20 | // SetAvailabilityChangeCallback dummy function |
18 | | -func (db *DBIndexer) SetAvailabilityChangeCallback(callback func(bool)) { |
| 21 | +func (i *DBIndexer) SetAvailabilityChangeCallback(callback func(bool)) { |
19 | 22 | } |
20 | 23 |
|
21 | 24 | // Ping checks if database is available |
22 | | -func (db *DBIndexer) Ping() bool { |
23 | | - return models.Ping() != nil |
| 25 | +func (i *DBIndexer) Ping() bool { |
| 26 | + return db.GetEngine(db.DefaultContext).Ping() != nil |
24 | 27 | } |
25 | 28 |
|
26 | 29 | // Index dummy function |
27 | | -func (db *DBIndexer) Index(issue []*IndexerData) error { |
| 30 | +func (i *DBIndexer) Index(issue []*IndexerData) error { |
28 | 31 | return nil |
29 | 32 | } |
30 | 33 |
|
31 | 34 | // Delete dummy function |
32 | | -func (db *DBIndexer) Delete(ids ...int64) error { |
| 35 | +func (i *DBIndexer) Delete(ids ...int64) error { |
33 | 36 | return nil |
34 | 37 | } |
35 | 38 |
|
36 | 39 | // Close dummy function |
37 | | -func (db *DBIndexer) Close() { |
| 40 | +func (i *DBIndexer) Close() { |
38 | 41 | } |
39 | 42 |
|
40 | 43 | // Search dummy function |
41 | | -func (db *DBIndexer) Search(kw string, repoIDs []int64, limit, start int) (*SearchResult, error) { |
| 44 | +func (i *DBIndexer) Search(kw string, repoIDs []int64, limit, start int) (*SearchResult, error) { |
42 | 45 | total, ids, err := models.SearchIssueIDsByKeyword(kw, repoIDs, limit, start) |
43 | 46 | if err != nil { |
44 | 47 | return nil, err |
|
0 commit comments