Skip to content

Instantly share code, notes, and snippets.

@davehunt
Created March 22, 2022 15:19
Show Gist options
  • Save davehunt/be4be75cfeacc5d3fbdc30af2b8b165a to your computer and use it in GitHub Desktop.
Save davehunt/be4be75cfeacc5d3fbdc30af2b8b165a to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta, time, timezone
import calendar
import bugzilla
from dateutil.relativedelta import relativedelta
PROD_URL = "bugzilla.mozilla.org"
bzapi = bugzilla.Bugzilla(PROD_URL)
query = bzapi.build_query(
keywords="perf-alert",
keywords_type="allwords",
)
REGRESSED_BY_NOT_EMPTY = {
"f1": "regressed_by",
"o1": "isnotempty",
}
REGRESSED_BY_CHANGED = {
"f1": "regressed_by",
"o1": "everchanged",
}
now = datetime.now(timezone.utc)
d = now - relativedelta(months=13)
for m in range(13):
_first, last = calendar.monthrange(d.year, d.month)
after = f"{d.year}-{d.month:02d}-01"
before = f"{d.year}-{d.month:02d}-{last:02d}"
query.update(
{
"chfield": "[Bug creation]",
"chfieldfrom": after,
"chfieldto": before,
}
)
query.update(REGRESSED_BY_NOT_EMPTY)
opened = bzapi.query(query)
query.update(REGRESSED_BY_CHANGED)
changed = bzapi.query(query)
print(
f"{after}: opened: {len(opened)}; updated: {len(changed)} ({int(len(changed) / len(opened) * 100)}%)"
)
d = d + relativedelta(months=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment