Skip to content

feat: Always give the present 10% of the distribution history's width#142

Merged
BayerC merged 9 commits intomainfrom
poc/fixed-current-area
Mar 6, 2026
Merged

feat: Always give the present 10% of the distribution history's width#142
BayerC merged 9 commits intomainfrom
poc/fixed-current-area

Conversation

@BayerC
Copy link
Copy Markdown
Owner

@BayerC BayerC commented Feb 26, 2026

Closes #65
Closes #141

image

@BayerC BayerC requested a review from cbachhuber February 26, 2026 06:46
@BayerC
Copy link
Copy Markdown
Owner Author

BayerC commented Feb 26, 2026

@cbachhuber just an idea how to solve that we always have 10% for the current data

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (cb5f9f3) to head (52bcefd).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #142   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          490       502   +12     
=========================================
+ Hits           490       502   +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cbachhuber
Copy link
Copy Markdown
Collaborator

This isn't a bad idea at all! It also doesn't suffer from the complications of my approaches. Should we go with this?

@cbachhuber cbachhuber changed the title poc: fixed current area feat: Always give present 10% of the width in distribution history Feb 28, 2026
Comment thread src/open_cups/plots.py
Comment on lines +108 to +120
timestamps = [
(snapshot.timestamp - latest_snapshot_time) / 60 for snapshot in status_history
]

timestamps_extended = add_future_timestamp(timestamps, relative_extension=0.1)

data = {"Time (minutes)": timestamps_extended}
for user_status in UserStatus:
counts = [snapshot.counts[user_status] for snapshot in status_history]
data[user_status.value] = [
snapshot.counts[user_status] for snapshot in status_history
]
*counts,
counts[-1],
] # repeat last value in future timestamp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered extracting all of this to a function that creates data. However, later in this function, we still need timestamps_extended, so I didn't extract that.

We could extract a function that computes data and also returns the time range. What do you think about that?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine

@cbachhuber
Copy link
Copy Markdown
Collaborator

cbachhuber commented Feb 28, 2026

@BayerC thanks again for the idea, you saved my sanity!

I've updated this PR, it's now ready to go in after #144 :)

@cbachhuber
Copy link
Copy Markdown
Collaborator

cbachhuber commented Feb 28, 2026

Also note 60ce7c9: I temporarily added the ability to speed up time via an env var for my experiments (sample usage: TIME_SCALE=20.0 uv run streamlit run main.py). This doesn't affect sampling frequency because of streamlit's limits, unfortunately. If affects everything else though and was thus very useful for my experiments.

Do you think we should keep that, @BayerC?

@cbachhuber cbachhuber marked this pull request as ready for review March 4, 2026 05:18
@cbachhuber cbachhuber enabled auto-merge (squash) March 4, 2026 05:18
@cbachhuber cbachhuber disabled auto-merge March 4, 2026 05:20
@cbachhuber
Copy link
Copy Markdown
Collaborator

@BayerC since the majority of changes now comes from me, can you review this PR and merge if you're happy?

Copy link
Copy Markdown
Collaborator

@cbachhuber cbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approving to make this mergeable after @BayerC's review

@cbachhuber cbachhuber changed the title feat: Always give present 10% of the width in distribution history feat: Always give the present 10% of the width in distribution history Mar 4, 2026
@cbachhuber cbachhuber changed the title feat: Always give the present 10% of the width in distribution history feat: Always give the present 10% of the distribution history's width Mar 4, 2026
@BayerC
Copy link
Copy Markdown
Owner Author

BayerC commented Mar 5, 2026

@sourcery-ai review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider handling or explicitly guarding against an empty status_history in show_status_history_chart / add_future_timestamp, since both currently assume at least one timestamp and will fail with timestamps[-1] or counts[-1] otherwise.
  • The relative_extension=0.1 magic value is now part of the chart semantics; it may be clearer to promote this to a named constant (similar to MAX_NUMBER_OF_TICKS) so the 10% extension behavior is easier to discover and tweak.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider handling or explicitly guarding against an empty `status_history` in `show_status_history_chart` / `add_future_timestamp`, since both currently assume at least one timestamp and will fail with `timestamps[-1]` or `counts[-1]` otherwise.
- The `relative_extension=0.1` magic value is now part of the chart semantics; it may be clearer to promote this to a named constant (similar to `MAX_NUMBER_OF_TICKS`) so the 10% extension behavior is easier to discover and tweak.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@BayerC
Copy link
Copy Markdown
Owner Author

BayerC commented Mar 5, 2026

image I dont see any time on the x-axis anympore is this intendet @cbachhuber

Comment thread src/open_cups/plots.py
)
from open_cups.types import UserStatus

MAX_NUMBER_OF_TICKS = 10
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt move this more closered (1 line above) where it is used?
Its very specific to the function

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, my thinking was to put the 'config' to the top of the file. Similar as with the color values.

I'm absolutely open to moving this inside the function, if you prefer.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer having it in the function since a more a named magic number than a config

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could do in follow up, get this merged!

@cbachhuber
Copy link
Copy Markdown
Collaborator

@BayerC wrote

I dont see any time on the x-axis anympore is this intendet @cbachhuber

In your screenshot, you actually see -1 and 0. Give it some more time for the integers to appear. We don't do sub-integer times on the x-axis, never have. Is this acceptable?

@BayerC BayerC merged commit 0e37961 into main Mar 6, 2026
13 checks passed
@BayerC
Copy link
Copy Markdown
Owner Author

BayerC commented Mar 6, 2026

@BayerC wrote

I dont see any time on the x-axis anympore is this intendet @cbachhuber

In your screenshot, you actually see -1 and 0. Give it some more time for the integers to appear. We don't do sub-integer times on the x-axis, never have. Is this acceptable?

its fine i waited not long enough

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 this pull request may close these issues.

after a longer time (hour) the x axis time label is unreadable Track user stats over time

2 participants