Create GetOldestEntityCreationTime method (#14515)
This method will be used by the ES index jobs in order to get the first timestamp to be used as the starting point when doing indexing tasks
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ef85001523
Коммит
f6c934d7e0
@@ -1779,3 +1779,26 @@ func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams
|
||||
|
||||
return model.MakePostSearchResults(posts, nil), nil
|
||||
}
|
||||
|
||||
func (s *SqlPostStore) GetOldestEntityCreationTime() (int64, *model.AppError) {
|
||||
query := s.getQueryBuilder().Select("MIN(min_createat) min_createat").
|
||||
Suffix(`FROM (
|
||||
(SELECT MIN(createat) min_createat FROM Posts)
|
||||
UNION
|
||||
(SELECT MIN(createat) min_createat FROM Users)
|
||||
UNION
|
||||
(SELECT MIN(createat) min_createat FROM Channels)
|
||||
) entities`)
|
||||
queryString, _, err := query.ToSql()
|
||||
if err != nil {
|
||||
return -1, model.NewAppError("SqlPostStore.GetOldestEntityCreationTime",
|
||||
"store.sql_post.get_oldest_entity_creation_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
row := s.GetReplica().Db.QueryRow(queryString)
|
||||
var oldest int64
|
||||
if err := row.Scan(&oldest); err != nil {
|
||||
return -1, model.NewAppError("SqlPostStore.GetOldestEntityCreationTime",
|
||||
"store.sql_post.get_oldest_entity_creation_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return oldest, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user