Skip to content

Commit

Permalink
[Issue 1541] Ran make lint on analytics folder (#1539)
Browse files Browse the repository at this point in the history
## Summary

Relates to #1541

### Time to review: __2 mins__

## Changes proposed

I ran `make lint` then committed most of the results. I didn't commit
all of the results because this isn't my code and so I don't want to
overstep. Which is to say, `make lint` produced even more changes that
you don't see in this PR. I think it would ideally be the responsibility
of the code author(s) to address those changes.

## Context for reviewers

This PR is necessary due to CI not actually checking if the lining is
being done. See #1541
for more details.
  • Loading branch information
coilysiren authored Mar 26, 2024
1 parent 8c21a7b commit 0a25ccc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
7 changes: 4 additions & 3 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ def calculate_sprint_burndown(
post_results=post_results,
)


@metrics_app.command(name="sprint_burnup")
def calculate_sprint_burnup(
sprint_file: Annotated[str, SPRINT_FILE_ARG],
issue_file: Annotated[str, ISSUE_FILE_ARG],
sprint: Annotated[str, SPRINT_ARG],
unit: Annotated[Unit, UNIT_ARG] = Unit.points.value, # type: ignore[assignment]
unit: Annotated[Unit, UNIT_ARG] = Unit.points.value, # type: ignore[assignment]
*, # makes the following args keyword only
show_results: Annotated[bool, SHOW_RESULTS_ARG] = False,
post_results: Annotated[bool, POST_RESULTS_ARG] = False,
) -> None:
"""Calculate the burnup of a particular sprint"""
# load the input data
"""Calculate the burnup of a particular sprint."""
# load the input data
sprint_data = SprintBoard.load_from_json_files(
sprint_file=sprint_file,
issue_file=issue_file,
Expand Down
6 changes: 4 additions & 2 deletions analytics/src/analytics/metrics/burndown.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
"""
from __future__ import annotations

from typing import Literal
from typing import TYPE_CHECKING, Literal

import pandas as pd
import plotly.express as px
from numpy import nan
from plotly.graph_objects import Figure

from analytics.datasets.sprint_board import SprintBoard
from analytics.metrics.base import BaseMetric, Statistic, Unit

if TYPE_CHECKING:
from plotly.graph_objects import Figure


class SprintBurndown(BaseMetric[SprintBoard]):
"""Calculates the running total of open issues per day in the sprint."""
Expand Down
7 changes: 4 additions & 3 deletions analytics/src/analytics/metrics/burnup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
"""
from __future__ import annotations

from typing import Literal
from typing import TYPE_CHECKING

import pandas as pd
import plotly.express as px
from numpy import nan
from plotly.graph_objects import Figure

from analytics.datasets.sprint_board import SprintBoard
from analytics.metrics.base import BaseMetric, Statistic, Unit
Expand All @@ -21,6 +19,9 @@
get_tix_date_range,
)

if TYPE_CHECKING:
from plotly.graph_objects import Figure


class SprintBurnup(BaseMetric[SprintBoard]):
"""Calculates the running total of open issues per day in the sprint."""
Expand Down
21 changes: 12 additions & 9 deletions analytics/src/analytics/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from analytics.metrics.base import Unit


def get_daily_tix_counts_by_status(df: pd.DataFrame,
status: Literal["opened", "closed"],
unit: Unit) -> pd.DataFrame:
def get_daily_tix_counts_by_status(
df: pd.DataFrame, status: Literal["opened", "closed"], unit: Unit,
) -> pd.DataFrame:
"""
Count the number of issues or points opened or closed by date.
Expand All @@ -30,9 +30,13 @@ def get_daily_tix_counts_by_status(df: pd.DataFrame,
df_agg = df[key_cols].groupby(agg_col, as_index=False).agg({unit_col: "sum"})
return df_agg.rename(columns={agg_col: "date", unit_col: status})

def get_tix_date_range(df: pd.DataFrame, open_col: str | None,
closed_col: str | None,
sprint_end: pd.Timestamp) -> pd.DataFrame:

def get_tix_date_range(
df: pd.DataFrame,
open_col: str | None,
closed_col: str | None,
sprint_end: pd.Timestamp,
) -> pd.DataFrame:
"""
Get the data range over which issues were created and closed.
Expand All @@ -52,9 +56,10 @@ def get_tix_date_range(df: pd.DataFrame, open_col: str | None,
closed_max = sprint_end if pd.isna(closed_max) else max(sprint_end, closed_max)
return pd.DataFrame(
pd.date_range(opened_min, closed_max),
columns = ["date"],
columns=["date"],
)


def get_cum_sum_of_tix(
dates: pd.DataFrame,
opened: pd.DataFrame,
Expand Down Expand Up @@ -83,5 +88,3 @@ def get_cum_sum_of_tix(
df["total_open"] = df["delta"].cumsum()
df["total_closed"] = df["closed"].cumsum()
return df


0 comments on commit 0a25ccc

Please sign in to comment.