Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.5.1
9 changes: 7 additions & 2 deletions metrics/legacy_matomo/opensearch_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def increment = params.document.containsKey(field) ? params.document[field] : 0;
ctx._source.applied_day_masks = params.empty_day_masks;
}
for (int index = 0; index < params.day_masks.size(); index++) {
if ((ctx._source.applied_day_masks[index] & params.day_masks[index]) != 0) {
// JSON zeroes may deserialize as Integer; force long before using high bits.
long currentMask = ((Number) ctx._source.applied_day_masks[index]).longValue();
long incomingMask = ((Number) params.day_masks[index]).longValue();
if ((currentMask & incomingMask) != 0) {
throw new IllegalStateException('Historical migration overlaps an applied analytics day');
}
}
Expand All @@ -78,7 +81,9 @@ def increment = params.document.containsKey(field) ? params.document[field] : 0;
ctx._source[field] = currentValue + increment;
}
for (int index = 0; index < params.day_masks.size(); index++) {
ctx._source.applied_day_masks[index] |= params.day_masks[index];
long currentMask = ((Number) ctx._source.applied_day_masks[index]).longValue();
long incomingMask = ((Number) params.day_masks[index]).longValue();
ctx._source.applied_day_masks[index] = currentMask | incomingMask;
}
ctx._source.applied_migrations.add(params.migration_id);
"""
Expand Down
16 changes: 16 additions & 0 deletions metrics/tests/services/test_legacy_matomo_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ def test_analytics_action_builds_all_day_masks(self):
day_masks[august_last_offset // 63] & (1 << (august_last_offset % 63))
)

def test_analytics_action_preserves_masks_larger_than_32_bits(self):
action = build_analytics_increment_action(
"usage_yearly_analytics_scl_2025",
"key",
METRICS,
"migration-with-hash",
["2025-09-01", "2025-09-30"],
)

day_masks = action["script"]["params"]["day_masks"]
script = action["script"]["source"]

self.assertGreater(max(day_masks), (1 << 31) - 1)
self.assertIn("((Number) params.day_masks[index]).longValue()", script)
self.assertNotIn("applied_day_masks[index] |=", script)

@override_settings(OPENSEARCH_INDEX_NAME="usage")
def test_preflight_builds_yearly_targets_without_writes(self):
collection = SimpleNamespace(
Expand Down
Loading