Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
Add median metric
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuchyna committed Feb 19, 2021
1 parent 4d4c4b4 commit 577ba97
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion srcopsmetrics/kebechet_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def get_overall_stats_update_manager(self):
stats["merged_by_kebechet_bot"] = len(prs[prs["merged_by_kebechet_bot"] == 1])
stats["merged_by_other"] = stats["merged"] - stats["merged_by_kebechet_bot"]

median_time = prs["ttm"].median()
stats["median_ttm"] = median_time if not np.isnan(median_time) else 0

return stats

def get_daily_stats_update_manager(self):
Expand All @@ -167,9 +170,10 @@ def get_daily_stats_update_manager(self):
"""
prs = self._get_update_manager_pull_requests()
prs["days"] = prs.apply(lambda x: datetime.fromtimestamp(x["date"]).date(), axis=1)
today = datetime.now().date()

stats: Dict[datetime, Any] = {}
day_range = [datetime.now().date()] if self.today else prs["days"].unique()
day_range = [today] if self.today else prs["days"].unique()
for date in day_range:
prs_day = prs[prs["days"] == date]

Expand All @@ -184,7 +188,11 @@ def get_daily_stats_update_manager(self):
day["merged_by_kebechet_bot"] = len(prs_day[prs_day["merged_by_kebechet_bot"] == 1])
day["merged_by_other"] = day["merged"] - day["merged_by_kebechet_bot"]

# TODO consider adding median_time to every day statistics (rolling windown maybe?)

if self.today:
median_time = prs[prs["days"] == today]["ttm"].median()
day["median_ttm"] = median_time if not np.isnan(median_time) else 0
return day

stats[str(date)] = day
Expand Down

0 comments on commit 577ba97

Please sign in to comment.