Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most recent changelogs are removed first #696

Closed
francesmcmullin opened this issue Mar 23, 2022 · 0 comments · Fixed by #698
Closed

Most recent changelogs are removed first #696

francesmcmullin opened this issue Mar 23, 2022 · 0 comments · Fixed by #698

Comments

@francesmcmullin
Copy link
Contributor

Describe the bug
When changelog history is restricted using max_history, the most recent entries are removed instead of older ones.

Expected behavior
The oldest changelog entries should be removed, so I can review for e.g., the 1,000 most recent entries.

Current behavior
Changelog entries are removed most recent first. Here's the relevant line:

local removed_entries = redis.call("ZREMRANGEBYRANK", changelog, max_history, -1)

Note, this removes entries from "start" of max_history, to -1, or the "end" of the sorted set. From the redis docs on ZREMRANGEBYRANK: "start and stop are 0 -based indexes with 0 being the element with the lowest score", and the score used a few lines above is the current time, so newer entries have higher scores.

Additional context
I recommend inverting the removal, this should work:

  local removed_entries = redis.call("ZREMRANGEBYRANK", changelog, 0, -1 * max_history)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant