Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
squad-track-duration: Update sorting to fix legend order
Browse files Browse the repository at this point in the history
Update the sorting of the data so it is sorted by the legend lines then
by created_at. This will ensure the data for each graph line is in the
correct order while also putting the legend in alphabetical order.

Signed-off-by: Katie Worton <[email protected]>
  • Loading branch information
katieworton authored and roxell committed May 14, 2024
1 parent 1d1d15b commit 430100f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions squad-track-duration
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,13 @@ def run():

mean_boottimes1 = df_grouping1["boottime"].mean()

# Convert the Series object back to a DataFrame then sort by the created_at
mean_boottimes1 = mean_boottimes1.reset_index().sort_values(by="created_at")
# Convert the Series object back to a DataFrame then sort values first by
# device, then by created_at. This will make the graph legend alphabetised
# while also ensuring the dates for each line are ordered by created_at so
# the graph's lines will be drawn correctly.
mean_boottimes1 = mean_boottimes1.reset_index().sort_values(
by=["device", "created_at"]
)

# Calculate how many boottimes we averaged over per device
count_per_device1 = df_grouping1["boottime"].count().groupby("device").sum()
Expand Down Expand Up @@ -369,10 +374,12 @@ def run():

mean_boottimes2 = df_grouping2["boottime"].mean()

# Convert the Series object back to a DataFrame then sort by the created_at
# and build_name_device
# Convert the Series object back to a DataFrame then sort values first by
# build_name_device, then by created_at. This will make the graph legend
# alphabetised while also ensuring the dates for each line are ordered by
# created_at so the graph's lines will be drawn correctly.
mean_boottimes2 = mean_boottimes2.reset_index().sort_values(
by=["created_at", "build_name_device"]
by=["build_name_device", "created_at"]
)

logger.debug(mean_boottimes2.info())
Expand Down

0 comments on commit 430100f

Please sign in to comment.