File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,18 @@ def add_record_change_ids(doc):
1313 """Add unique_id and aggregation_id to the doc."""
1414
1515 # We use this field to group by during aggregation.
16- # e.g. the count of created eitems by a user with id 7 is tracked under eitmid__insert__None .
17- doc ["aggregation_id" ] = f"{ doc ['pid_type' ]} __{ doc ['method' ]} __ { doc [ 'user_id' ] } "
16+ # e.g. the count of created eitems by a user with id 7 is tracked under eitmid__insert__7 .
17+ doc ["aggregation_id" ] = f"{ doc ['pid_type' ]} __{ doc ['method' ]} "
1818
1919 # unique_id identifies each individual event and is used by invenio-stats.
2020 # It automatically deduplicates events from the same second that have the same unique_id.
2121 # Including the pid_value ensures distinctness between events,
2222 # even when multiple records are updated within the same second.
2323 # e.g. during the importer in cds-ils where many eitems are created in bulk.
24- doc ["unique_id" ] = (
25- f"{ doc ['pid_value' ]} __{ doc ['pid_type' ]} __{ doc ['method' ]} __{ doc ['user_id' ]} "
26- )
24+ doc ["unique_id" ] = f"{ doc ['pid_value' ]} __{ doc ['pid_type' ]} __{ doc ['method' ]} "
25+
26+ if doc ["user_id" ]:
27+ doc ["aggregation_id" ] += f"__{ doc ['user_id' ]} "
28+ doc ["unique_id" ] += f"__{ doc ['user_id' ]} "
2729
2830 return doc
You can’t perform that action at this time.
0 commit comments