yeref 0.24.72__tar.gz → 0.24.74__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.24.72
3
+ Version: 0.24.74
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name='yeref',
5
- version='0.24.72',
5
+ version='0.24.74',
6
6
  description='desc-f',
7
7
  author='john smith',
8
8
  packages=['yeref'],
@@ -16496,39 +16496,39 @@ async def return_retention_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
16496
16496
  if not cohort_months:
16497
16497
  return
16498
16498
 
16499
- max_offset = 0
16500
- for c in cohort_months:
16501
- if rev_by_cohort[c]:
16502
- max_offset = max(max_offset, max(rev_by_cohort[c].keys()))
16499
+ def add_months(mo_str, n):
16500
+ y, m = map(int, mo_str.split("-"))
16501
+ total = m + n
16502
+ new_y = y + (total - 1) // 12
16503
+ new_m = (total - 1) % 12 + 1
16504
+ return f"{new_y:04d}-{new_m:02d}"
16503
16505
 
16504
- base_rev = {c: rev_by_cohort[c].get(0, 0.0) for c in cohort_months}
16506
+ num_cohorts = len(cohort_months)
16507
+ first_cohort = cohort_months[0]
16505
16508
 
16506
16509
  path = os.path.join(EXTRA_D, "4_retention_metrics.csv")
16507
16510
  with open(path, "w", newline="", encoding="utf-8") as f:
16508
16511
  writer = csv.writer(f)
16509
- header = ["Месяц / Когорта"] + [
16512
+ header = ["Месяц/Когорта"] + [
16510
16513
  f"{c} ({len(cohort_users[c])})" for c in cohort_months
16511
16514
  ] + ["∑"]
16512
16515
  writer.writerow(header)
16513
16516
 
16514
- for i in range(max_offset + 1):
16515
- row = [f"M{i+1} ({i} мес)"]
16517
+ for i in range(num_cohorts):
16518
+ calendar_mo = add_months(first_cohort, i)
16519
+ row = [f"M{i+1}"]
16516
16520
  row_sum = 0.0
16517
16521
  for c in cohort_months:
16518
- rev = rev_by_cohort[c].get(i, 0.0)
16519
- if i == 0:
16520
- pct = 100
16521
- cell = f"{rev:.1f} ({pct}%)"
16522
- row.append(cell)
16523
- row_sum += rev
16522
+ y0, m0 = map(int, c.split("-"))
16523
+ y1, m1 = map(int, calendar_mo.split("-"))
16524
+ offset = (y1 - y0) * 12 + (m1 - m0)
16525
+ if offset < 0:
16526
+ cell = "0.0"
16524
16527
  else:
16525
- if base_rev[c] > 0 and rev > 0:
16526
- pct = rev / base_rev[c] * 100
16527
- cell = f"{rev:.1f} ({pct:.0f}%)"
16528
- row.append(cell)
16529
- row_sum += rev
16530
- else:
16531
- row.append("")
16528
+ rev = rev_by_cohort[c].get(offset, 0.0)
16529
+ cell = f"{rev:.1f}"
16530
+ row_sum += rev
16531
+ row.append(cell)
16532
16532
  row.append(f"{row_sum:.1f}")
16533
16533
  writer.writerow(row)
16534
16534
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.24.72
3
+ Version: 0.24.74
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
File without changes
File without changes
File without changes
File without changes
File without changes