lists_test: add timestamps to RoomConnMetadata

This commit is contained in:
David Robertson 2023-05-25 14:45:55 +01:00
parent d8f158b292
commit 5f3c9dff3c
No known key found for this signature in database
GPG Key ID: 903ECE108A39DEDD
2 changed files with 17 additions and 1 deletions

View File

@ -156,6 +156,18 @@ func (s *InternalRequestLists) Get(listKey string) *FilteredSortableRooms {
return s.lists[listKey]
}
// ListKeys returns a copy of the list keys currently tracked by this
// InternalRequestLists struct, in no particular order. Outside of test code, you
// probably don't want to call this---you probably have the set of list keys tracked
// elsewhere in the application.
func (s *InternalRequestLists) ListKeys() []string {
keys := make([]string, len(s.lists))
for listKey, _ := range s.lists {
keys = append(keys, listKey)
}
return keys
}
// ListsByVisibleRoomIDs builds a map from room IDs to a slice of list names. Keys are
// all room IDs that are currently visible in at least one sliding window. Values are
// the names of all lists (in no particular order) in which the given room ID is

View File

@ -31,6 +31,10 @@ func addRooms(list *sync3.InternalRequestLists, n int) {
for i := 0; i < n; i++ {
next := roomCounter.Add(1)
messageTimestamp := uint64(timestamp.Add(time.Duration(next) * time.Minute).UnixMilli())
lastInterestedEventTimestamps := make(map[string]uint64)
for _, listKey := range list.ListKeys() {
lastInterestedEventTimestamps[listKey] = messageTimestamp
}
list.SetRoom(sync3.RoomConnMetadata{
RoomMetadata: internal.RoomMetadata{
RoomID: fmt.Sprintf("!%d:benchmark", next),
@ -41,7 +45,7 @@ func addRooms(list *sync3.InternalRequestLists, n int) {
UserRoomData: caches.UserRoomData{
IsDM: next%10 == 0,
},
LastInterestedEventTimestamps: make(map[string]uint64),
LastInterestedEventTimestamps: lastInterestedEventTimestamps,
})
}
}