1
1
import { deprecate } from '@ember/debug' ;
2
2
3
+ import { LOG_METRIC_COUNTS } from '@warp-drive/build-config/debugging' ;
3
4
import { DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE } from '@warp-drive/build-config/deprecations' ;
4
5
import { DEBUG } from '@warp-drive/build-config/env' ;
5
6
import { assert } from '@warp-drive/build-config/macros' ;
@@ -12,6 +13,12 @@ import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
12
13
import type { CollectionEdge } from '../edges/collection' ;
13
14
import type { Graph } from '../graph' ;
14
15
16
+ function count ( label : string ) {
17
+ // @ts -expect-error
18
+ // eslint-disable-next-line
19
+ globalThis . __WarpDriveMetricCountData [ label ] = ( globalThis . __WarpDriveMetricCountData [ label ] || 0 ) + 1 ;
20
+ }
21
+
15
22
/*
16
23
case many:1
17
24
========
@@ -75,7 +82,6 @@ export default function replaceRelatedRecords(graph: Graph, op: ReplaceRelatedRe
75
82
}
76
83
}
77
84
78
- // FIXME: Add metric count for number of calls to this
79
85
function replaceRelatedRecordsLocal ( graph : Graph , op : ReplaceRelatedRecordsOperation , isRemote : boolean ) {
80
86
const identifiers = op . value ;
81
87
const relationship = graph . get ( op . record , op . field ) ;
@@ -88,6 +94,10 @@ function replaceRelatedRecordsLocal(graph: Graph, op: ReplaceRelatedRecordsOpera
88
94
const wasDirty = relationship . isDirty ;
89
95
let localBecameDirty = false ;
90
96
97
+ if ( LOG_METRIC_COUNTS ) {
98
+ count ( `replaceRelatedRecordsLocal ${ 'type' in record ? record . type : '<document>' } ${ op . field } ` ) ;
99
+ }
100
+
91
101
const onAdd = ( identifier : StableRecordIdentifier ) => {
92
102
// Since we are diffing against the remote state, we check
93
103
// if our previous local state did not contain this identifier
@@ -161,11 +171,14 @@ function replaceRelatedRecordsLocal(graph: Graph, op: ReplaceRelatedRecordsOpera
161
171
}
162
172
}
163
173
164
- // FIXME: Add metric count for number of calls to this
165
174
function replaceRelatedRecordsRemote ( graph : Graph , op : ReplaceRelatedRecordsOperation , isRemote : boolean ) {
166
175
const identifiers = op . value ;
167
176
const relationship = graph . get ( op . record , op . field ) ;
168
177
178
+ if ( LOG_METRIC_COUNTS ) {
179
+ count ( `replaceRelatedRecordsRemote ${ 'type' in op . record ? op . record . type : '<document>' } ${ op . field } ` ) ;
180
+ }
181
+
169
182
assert (
170
183
`You can only '${ op . op } ' on a hasMany relationship. ${ op . record . type } .${ op . field } is a ${ relationship . definition . kind } ` ,
171
184
isHasMany ( relationship )
0 commit comments