Just a quick POC to move fast :P

We use a search pointer to keep track of
the next row to inesrt to. For every new search
we increment the pointer and do modulo 5.
This means that the value will always remain
between 0-4. And that way, we will always overwrite
the oldest entry on every search.

And while getting the results, we get
all results for that user.

The search parameters are json marshalled
and stored as a JSON blob. This is because
there is no need to search/filter them
in the DB.

Pending items:
Tests obviously.

To improve:
The client needs to send the channel ids
instead of channel names.
Этот коммит содержится в:
Agniva De Sarker
2022-05-16 13:16:11 +05:30
коммит произвёл GitHub
родитель 979b616189
Коммит aa59c28b04
26 изменённых файлов: 488 добавлений и 68 удалений

Просмотреть файл

@@ -610,6 +610,29 @@ func (_m *PostStore) GetPostsSinceForSync(options model.GetPostsSinceForSyncOpti
return r0, r1, r2
}
// GetRecentSearchesForUser provides a mock function with given fields: userID
func (_m *PostStore) GetRecentSearchesForUser(userID string) ([]*model.SearchParams, error) {
ret := _m.Called(userID)
var r0 []*model.SearchParams
if rf, ok := ret.Get(0).(func(string) []*model.SearchParams); ok {
r0 = rf(userID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.SearchParams)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(userID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetRepliesForExport provides a mock function with given fields: parentID
func (_m *PostStore) GetRepliesForExport(parentID string) ([]*model.ReplyForExport, error) {
ret := _m.Called(parentID)
@@ -682,6 +705,20 @@ func (_m *PostStore) InvalidateLastPostTimeCache(channelID string) {
_m.Called(channelID)
}
// LogRecentSearch provides a mock function with given fields: userID, searchQuery, createAt
func (_m *PostStore) LogRecentSearch(userID string, searchQuery []byte, createAt int64) error {
ret := _m.Called(userID, searchQuery, createAt)
var r0 error
if rf, ok := ret.Get(0).(func(string, []byte, int64) error); ok {
r0 = rf(userID, searchQuery, createAt)
} else {
r0 = ret.Error(0)
}
return r0
}
// Overwrite provides a mock function with given fields: post
func (_m *PostStore) Overwrite(post *model.Post) (*model.Post, error) {
ret := _m.Called(post)