Skip to content

Commit c034cb3

Browse files
author
Jeff Yanta
committed
chat: remove prisma from postgres store
1 parent 4fabdb5 commit c034cb3

File tree

12 files changed

+738
-989
lines changed

12 files changed

+738
-989
lines changed

chat/memory/store.go

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/code-payments/flipchat-server/chat"
1919
"github.com/code-payments/flipchat-server/protoutil"
20-
"github.com/code-payments/flipchat-server/query"
2120
)
2221

2322
type InMemoryStore struct {
@@ -82,7 +81,7 @@ func (s *InMemoryStore) GetChatMetadataBatched(ctx context.Context, chatIDs ...*
8281
return protoutil.SliceClone(metadata), nil
8382
}
8483

85-
func (s *InMemoryStore) GetChatsForUser(_ context.Context, userID *commonpb.UserId, opts ...query.Option) ([]*commonpb.ChatId, error) {
84+
func (s *InMemoryStore) GetChatsForUser(_ context.Context, userID *commonpb.UserId) ([]*commonpb.ChatId, error) {
8685
s.mu.RLock()
8786
defer s.mu.RUnlock()
8887

@@ -92,39 +91,6 @@ func (s *InMemoryStore) GetChatsForUser(_ context.Context, userID *commonpb.User
9291
for _, chatIDString := range chatIDStrings {
9392
chatIDs = append(chatIDs, &commonpb.ChatId{Value: []byte(chatIDString)})
9493
}
95-
96-
queryOpts := query.DefaultOptions()
97-
for _, o := range opts {
98-
o(&queryOpts)
99-
}
100-
101-
slices.SortFunc(chatIDs, func(a, b *commonpb.ChatId) int {
102-
if queryOpts.Order == commonpb.QueryOptions_ASC {
103-
return bytes.Compare(a.GetValue(), b.GetValue())
104-
} else {
105-
return -1 * bytes.Compare(a.GetValue(), b.GetValue())
106-
}
107-
})
108-
109-
if queryOpts.Token != nil {
110-
for i := range chatIDs {
111-
cmp := bytes.Compare(chatIDs[i].GetValue(), queryOpts.Token.GetValue())
112-
if queryOpts.Order == commonpb.QueryOptions_DESC {
113-
cmp *= -1
114-
}
115-
if cmp <= 0 {
116-
continue
117-
} else {
118-
chatIDs = chatIDs[i:]
119-
break
120-
}
121-
}
122-
}
123-
124-
if queryOpts.Limit > 0 {
125-
chatIDs = chatIDs[:min(queryOpts.Limit, len(chatIDs))]
126-
}
127-
12894
return chatIDs, nil
12995
}
13096

0 commit comments

Comments
 (0)