mirror of
https://github.com/bugsink/bugsink.git
synced 2025-12-21 13:00:13 -06:00
issue.stored_event_count: consequences for 'irrelevance'
document & assert
This commit is contained in:
@@ -83,6 +83,9 @@ def get_random_irrelevance(stored_event_count):
|
||||
if `cnt` "hovers" around a certain value (which is likely to happen when there's repeated eviction/fill-up). ×2 is
|
||||
simply to correct for random() (which returns .5 on average).
|
||||
"""
|
||||
# assert as a tripwire to check our assumptions; note that the actual calculation actually "succeeds" for < 1, but
|
||||
# it becomes non-sensical, so I'd rather have it fail. The present event is part of the count, i.e. always >= 1
|
||||
assert stored_event_count >= 1
|
||||
return nonzero_leading_bits(round(random() * stored_event_count * 2))
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ def fill_stored_event_count(apps, schema_editor):
|
||||
issue.stored_event_count = correct_value
|
||||
issue.save()
|
||||
|
||||
# Note: because "irrelevances" have been calculated based on stored_event_count, those will be wrong too... but
|
||||
# there doesn't seem to be an easy way to recover from that, so we'll just let the problem fix itself over time.
|
||||
# easy meaning: both easy-enough to write a datamigration for, and not super-expensive to run.
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user