Coffee journaling on ATProto (alpha) alpha.arabica.social
coffee
17
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: query ordering

+17 -6
+15 -4
internal/firehose/index.go
··· 1156 1156 return dids, rows.Err() 1157 1157 } 1158 1158 1159 - // ListRecordsByCollection returns all indexed records for a given collection. 1159 + // ListRecordsByCollection returns all indexed records for a given collection, 1160 + // ordered by created_at DESC (newest first). 1160 1161 func (idx *FeedIndex) ListRecordsByCollection(ctx context.Context, collection string) ([]IndexedRecord, error) { 1161 - rows, err := idx.db.QueryContext(ctx, ` 1162 + return idx.listRecordsByCollection(ctx, collection, "DESC") 1163 + } 1164 + 1165 + // ListRecordsByCollectionOldest returns all indexed records for a given collection, 1166 + // ordered by created_at ASC (oldest first). 1167 + func (idx *FeedIndex) ListRecordsByCollectionOldest(ctx context.Context, collection string) ([]IndexedRecord, error) { 1168 + return idx.listRecordsByCollection(ctx, collection, "ASC") 1169 + } 1170 + 1171 + func (idx *FeedIndex) listRecordsByCollection(ctx context.Context, collection string, dir string) ([]IndexedRecord, error) { 1172 + rows, err := idx.db.QueryContext(ctx, fmt.Sprintf(` 1162 1173 SELECT uri, did, collection, rkey, record, cid, indexed_at, created_at 1163 - FROM records WHERE collection = ? ORDER BY created_at ASC 1164 - `, collection) 1174 + FROM records WHERE collection = ? ORDER BY created_at %s 1175 + `, dir), collection) 1165 1176 if err != nil { 1166 1177 return nil, err 1167 1178 }
+2 -2
internal/suggestions/suggestions.go
··· 21 21 22 22 // RecordSource provides read access to indexed records. 23 23 type RecordSource interface { 24 - ListRecordsByCollection(ctx context.Context, collection string) ([]firehose.IndexedRecord, error) 24 + ListRecordsByCollectionOldest(ctx context.Context, collection string) ([]firehose.IndexedRecord, error) 25 25 } 26 26 27 27 // entityFieldConfig defines which fields to extract and search for each entity type ··· 230 230 skipDID = excludeDID[0] 231 231 } 232 232 233 - records, err := source.ListRecordsByCollection(ctx, collection) 233 + records, err := source.ListRecordsByCollectionOldest(ctx, collection) 234 234 if err != nil { 235 235 return nil, err 236 236 }