Skip to content

Commit 235d104

Browse files
committed
move code indexer related code to a new package
1 parent 33fc48c commit 235d104

File tree

8 files changed

+417
-376
lines changed

8 files changed

+417
-376
lines changed

models/models.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,28 @@ func MaxBatchInsertSize(bean interface{}) int {
254254
func Count(bean interface{}) (int64, error) {
255255
return x.Count(bean)
256256
}
257+
258+
// IsTableNotEmpty returns true if table has at least one record
259+
func IsTableNotEmpty(tableName string) (bool, error) {
260+
return x.Table(tableName).Exist()
261+
}
262+
263+
// DeleteAllRecords will delete all the records of this table
264+
func DeleteAllRecords(tableName string) error {
265+
_, err := x.Exec(fmt.Sprintf("DELETE FROM %s", tableName))
266+
return err
267+
}
268+
269+
// GetMaxID will return max id of the table
270+
func GetMaxID(tableName string) (maxID int64, err error) {
271+
_, err = x.Select("MAX(id)").Table(tableName).Get(&maxID)
272+
return
273+
}
274+
275+
// FindByMaxID filled results as the condition from database
276+
func FindByMaxID(maxID int64, limit int, results interface{}) error {
277+
return x.Where("id <= ?", maxID).
278+
OrderBy("id DESC").
279+
Limit(limit).
280+
Find(results)
281+
}

models/repo.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,6 @@ func MigrateRepositoryGitData(doer, u *User, repo *Repository, opts api.MigrateR
11011101
repo, err = CleanUpMigrateInfo(repo)
11021102
}
11031103

1104-
if err != nil && !repo.IsEmpty {
1105-
UpdateRepoIndexer(repo)
1106-
}
1107-
11081104
return repo, err
11091105
}
11101106

0 commit comments

Comments
 (0)