Skip to content

Commit 8a18485

Browse files
chore: refTo -> referencing
1 parent ead0664 commit 8a18485

File tree

12 files changed

+176
-150
lines changed

12 files changed

+176
-150
lines changed

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/comment/comment_repository.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ final class DocumentsCommentRepository implements CommentRepository {
105105
.watchDocuments(
106106
type: DocumentType.commentDocument,
107107
refGetter: (data) => data.metadata.template!,
108-
refTo: ref,
108+
referencing: ref,
109109
)
110110
.map(
111111
(documents) {

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/database/dao/documents_v2_dao.dart

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ abstract interface class DocumentsV2Dao {
1515
/// [ref] filters by the document's own identity.
1616
/// - If [DocumentRef.isExact], counts matches for that specific version.
1717
/// - If [DocumentRef.isLoose], counts all versions of that document ID.
18-
/// [refTo] filters documents that *reference* the given target.
19-
/// - Example: Count all comments ([type]=comment) that point to proposal X ([refTo]=X).
18+
/// [referencing] filters documents that *reference* the given target.
19+
/// - Example: Count all comments ([type]=comment) that point to proposal X ([referencing]=X).
2020
Future<int> count({
2121
DocumentType? type,
2222
DocumentRef? ref,
23-
DocumentRef? refTo,
23+
DocumentRef? referencing,
2424
});
2525

2626
/// Deletes documents from the database, preserving those with types in [typeNotIn].
@@ -57,7 +57,7 @@ abstract interface class DocumentsV2Dao {
5757
Future<DocumentEntityV2?> getDocument({
5858
DocumentType? type,
5959
DocumentRef? ref,
60-
DocumentRef? refTo,
60+
DocumentRef? referencing,
6161
CatalystId? author,
6262
});
6363

@@ -73,7 +73,7 @@ abstract interface class DocumentsV2Dao {
7373
Future<List<DocumentEntityV2>> getDocuments({
7474
DocumentType? type,
7575
DocumentRef? ref,
76-
DocumentRef? refTo,
76+
DocumentRef? referencing,
7777
CampaignFilters? filters,
7878
bool latestOnly,
7979
int limit,
@@ -106,7 +106,7 @@ abstract interface class DocumentsV2Dao {
106106
Stream<int> watchCount({
107107
DocumentType? type,
108108
DocumentRef? ref,
109-
DocumentRef? refTo,
109+
DocumentRef? referencing,
110110
});
111111

112112
/// Watches for changes to a specific document query.
@@ -116,7 +116,7 @@ abstract interface class DocumentsV2Dao {
116116
Stream<DocumentEntityV2?> watchDocument({
117117
DocumentType? type,
118118
DocumentRef? ref,
119-
DocumentRef? refTo,
119+
DocumentRef? referencing,
120120
CatalystId? author,
121121
});
122122

@@ -130,7 +130,7 @@ abstract interface class DocumentsV2Dao {
130130
Stream<List<DocumentEntityV2>> watchDocuments({
131131
DocumentType? type,
132132
DocumentRef? ref,
133-
DocumentRef? refTo,
133+
DocumentRef? referencing,
134134
CampaignFilters? filters,
135135
bool latestOnly,
136136
int limit,
@@ -153,9 +153,13 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
153153
Future<int> count({
154154
DocumentType? type,
155155
DocumentRef? ref,
156-
DocumentRef? refTo,
156+
DocumentRef? referencing,
157157
}) {
158-
return _queryCount(type: type, ref: ref, refTo: refTo).getSingle().then((value) => value ?? 0);
158+
return _queryCount(
159+
type: type,
160+
ref: ref,
161+
referencing: referencing,
162+
).getSingle().then((value) => value ?? 0);
159163
}
160164

161165
@override
@@ -226,17 +230,22 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
226230
Future<DocumentEntityV2?> getDocument({
227231
DocumentType? type,
228232
DocumentRef? ref,
229-
DocumentRef? refTo,
233+
DocumentRef? referencing,
230234
CatalystId? author,
231235
}) {
232-
return _queryDocument(type: type, ref: ref, refTo: refTo, author: author).getSingleOrNull();
236+
return _queryDocument(
237+
type: type,
238+
ref: ref,
239+
referencing: referencing,
240+
author: author,
241+
).getSingleOrNull();
233242
}
234243

235244
@override
236245
Future<List<DocumentEntityV2>> getDocuments({
237246
DocumentType? type,
238247
DocumentRef? ref,
239-
DocumentRef? refTo,
248+
DocumentRef? referencing,
240249
CampaignFilters? filters,
241250
bool latestOnly = false,
242251
int limit = 200,
@@ -245,7 +254,7 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
245254
return _queryDocuments(
246255
type: type,
247256
ref: ref,
248-
refTo: refTo,
257+
referencing: referencing,
249258
filters: filters,
250259
latestOnly: latestOnly,
251260
limit: limit,
@@ -302,26 +311,35 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
302311
Stream<int> watchCount({
303312
DocumentType? type,
304313
DocumentRef? ref,
305-
DocumentRef? refTo,
314+
DocumentRef? referencing,
306315
}) {
307-
return _queryCount(type: type, ref: ref, refTo: refTo).watchSingle().map((value) => value ?? 0);
316+
return _queryCount(
317+
type: type,
318+
ref: ref,
319+
referencing: referencing,
320+
).watchSingle().map((value) => value ?? 0);
308321
}
309322

310323
@override
311324
Stream<DocumentEntityV2?> watchDocument({
312325
DocumentType? type,
313326
DocumentRef? ref,
314-
DocumentRef? refTo,
327+
DocumentRef? referencing,
315328
CatalystId? author,
316329
}) {
317-
return _queryDocument(type: type, ref: ref, refTo: refTo, author: author).watchSingleOrNull();
330+
return _queryDocument(
331+
type: type,
332+
ref: ref,
333+
referencing: referencing,
334+
author: author,
335+
).watchSingleOrNull();
318336
}
319337

320338
@override
321339
Stream<List<DocumentEntityV2>> watchDocuments({
322340
DocumentType? type,
323341
DocumentRef? ref,
324-
DocumentRef? refTo,
342+
DocumentRef? referencing,
325343
CampaignFilters? filters,
326344
bool latestOnly = false,
327345
int limit = 200,
@@ -330,7 +348,7 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
330348
return _queryDocuments(
331349
type: type,
332350
ref: ref,
333-
refTo: refTo,
351+
referencing: referencing,
334352
filters: filters,
335353
latestOnly: latestOnly,
336354
limit: limit,
@@ -341,7 +359,7 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
341359
Selectable<int?> _queryCount({
342360
DocumentType? type,
343361
DocumentRef? ref,
344-
DocumentRef? refTo,
362+
DocumentRef? referencing,
345363
}) {
346364
final count = countAll();
347365
final query = selectOnly(documentsV2)..addColumns([count]);
@@ -358,11 +376,11 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
358376
}
359377
}
360378

361-
if (refTo != null) {
362-
query.where(documentsV2.refId.equals(refTo.id));
379+
if (referencing != null) {
380+
query.where(documentsV2.refId.equals(referencing.id));
363381

364-
if (refTo.isExact) {
365-
query.where(documentsV2.refVer.equals(refTo.version!));
382+
if (referencing.isExact) {
383+
query.where(documentsV2.refVer.equals(referencing.version!));
366384
}
367385
}
368386

@@ -372,7 +390,7 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
372390
Selectable<DocumentEntityV2> _queryDocument({
373391
DocumentType? type,
374392
DocumentRef? ref,
375-
DocumentRef? refTo,
393+
DocumentRef? referencing,
376394
CatalystId? author,
377395
}) {
378396
final query = select(documentsV2);
@@ -385,11 +403,11 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
385403
}
386404
}
387405

388-
if (refTo != null) {
389-
query.where((tbl) => tbl.refId.equals(refTo.id));
406+
if (referencing != null) {
407+
query.where((tbl) => tbl.refId.equals(referencing.id));
390408

391-
if (refTo.isExact) {
392-
query.where((tbl) => tbl.refVer.equals(refTo.version!));
409+
if (referencing.isExact) {
410+
query.where((tbl) => tbl.refVer.equals(referencing.version!));
393411
}
394412
}
395413

@@ -421,7 +439,7 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
421439
SimpleSelectStatement<$DocumentsV2Table, DocumentEntityV2> _queryDocuments({
422440
DocumentType? type,
423441
DocumentRef? ref,
424-
DocumentRef? refTo,
442+
DocumentRef? referencing,
425443
CampaignFilters? filters,
426444
required bool latestOnly,
427445
required int limit,
@@ -442,11 +460,11 @@ class DriftDocumentsV2Dao extends DatabaseAccessor<DriftCatalystDatabase>
442460
}
443461
}
444462

445-
if (refTo != null) {
446-
query.where((tbl) => tbl.refId.equals(refTo.id));
463+
if (referencing != null) {
464+
query.where((tbl) => tbl.refId.equals(referencing.id));
447465

448-
if (refTo.isExact) {
449-
query.where((tbl) => tbl.refVer.equals(refTo.version!));
466+
if (referencing.isExact) {
467+
query.where((tbl) => tbl.refVer.equals(referencing.version!));
450468
}
451469
}
452470

0 commit comments

Comments
 (0)