yeref 0.24.70__tar.gz → 0.24.72__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.
- {yeref-0.24.70 → yeref-0.24.72}/PKG-INFO +1 -1
- {yeref-0.24.70 → yeref-0.24.72}/setup.py +1 -1
- {yeref-0.24.70 → yeref-0.24.72}/yeref/yeref.py +17 -30
- {yeref-0.24.70 → yeref-0.24.72}/yeref.egg-info/PKG-INFO +1 -1
- {yeref-0.24.70 → yeref-0.24.72}/pyproject.toml +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/setup.cfg +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref/__init__.py +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref/l_.py +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref/tonweb.js +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref.egg-info/SOURCES.txt +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref.egg-info/dependency_links.txt +0 -0
- {yeref-0.24.70 → yeref-0.24.72}/yeref.egg-info/top_level.txt +0 -0
@@ -16469,7 +16469,6 @@ async def return_retention_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16469
16469
|
))
|
16470
16470
|
print(f"gen {data_users=}")
|
16471
16471
|
|
16472
|
-
# Собираем платежи и дату входа для каждого пользователя
|
16473
16472
|
rev_by_cohort = defaultdict(lambda: defaultdict(float))
|
16474
16473
|
cohort_users = defaultdict(set)
|
16475
16474
|
|
@@ -16485,7 +16484,6 @@ async def return_retention_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16485
16484
|
for pay in USER_LSTS.get("USER_PAYMENTS", []):
|
16486
16485
|
dt_pay = datetime.strptime(pay.get("DT_START", ""), "%d-%m-%Y_%H-%M-%S")
|
16487
16486
|
pay_mo = dt_pay.strftime("%Y-%m")
|
16488
|
-
# вычисляем разницу в месяцах
|
16489
16487
|
y0, m0 = map(int, cohort_mo.split("-"))
|
16490
16488
|
y1, m1 = map(int, pay_mo.split("-"))
|
16491
16489
|
offset = (y1 - y0) * 12 + (m1 - m0)
|
@@ -16495,56 +16493,45 @@ async def return_retention_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16495
16493
|
rev_by_cohort[cohort_mo][offset] += amt
|
16496
16494
|
|
16497
16495
|
cohort_months = sorted(cohort_users.keys())
|
16498
|
-
|
16496
|
+
if not cohort_months:
|
16497
|
+
return
|
16498
|
+
|
16499
16499
|
max_offset = 0
|
16500
16500
|
for c in cohort_months:
|
16501
16501
|
if rev_by_cohort[c]:
|
16502
16502
|
max_offset = max(max_offset, max(rev_by_cohort[c].keys()))
|
16503
16503
|
|
16504
|
-
# Сумма выручки M1 для каждой когорты
|
16505
16504
|
base_rev = {c: rev_by_cohort[c].get(0, 0.0) for c in cohort_months}
|
16506
16505
|
|
16507
|
-
# Формируем CSV-таблицу
|
16508
16506
|
path = os.path.join(EXTRA_D, "4_retention_metrics.csv")
|
16509
16507
|
with open(path, "w", newline="", encoding="utf-8") as f:
|
16510
16508
|
writer = csv.writer(f)
|
16511
|
-
|
16512
|
-
|
16513
|
-
|
16514
|
-
header.append(f"{c} ({len(cohort_users[c])})")
|
16515
|
-
header.append("∑")
|
16509
|
+
header = ["Месяц / Когорта"] + [
|
16510
|
+
f"{c} ({len(cohort_users[c])})" for c in cohort_months
|
16511
|
+
] + ["∑"]
|
16516
16512
|
writer.writerow(header)
|
16517
16513
|
|
16518
|
-
# Строки M1..M{max_offset+1}
|
16519
16514
|
for i in range(max_offset + 1):
|
16520
|
-
|
16521
|
-
row = [row_label]
|
16515
|
+
row = [f"M{i+1} ({i} мес)"]
|
16522
16516
|
row_sum = 0.0
|
16523
16517
|
for c in cohort_months:
|
16524
16518
|
rev = rev_by_cohort[c].get(i, 0.0)
|
16525
|
-
if
|
16526
|
-
pct =
|
16527
|
-
cell = f"{rev:.1f} ({pct
|
16519
|
+
if i == 0:
|
16520
|
+
pct = 100
|
16521
|
+
cell = f"{rev:.1f} ({pct}%)"
|
16528
16522
|
row.append(cell)
|
16529
16523
|
row_sum += rev
|
16530
16524
|
else:
|
16531
|
-
|
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("")
|
16532
16532
|
row.append(f"{row_sum:.1f}")
|
16533
16533
|
writer.writerow(row)
|
16534
16534
|
|
16535
|
-
# Средний рост NRR
|
16536
|
-
growths = []
|
16537
|
-
for c in cohort_months:
|
16538
|
-
for i in range(1, max_offset + 1):
|
16539
|
-
prev = rev_by_cohort[c].get(i - 1, 0.0)
|
16540
|
-
curr = rev_by_cohort[c].get(i, 0.0)
|
16541
|
-
if prev > 0:
|
16542
|
-
growths.append((curr - prev) / prev)
|
16543
|
-
avg_growth = (sum(growths) / len(growths) * 100) if growths else 0.0
|
16544
|
-
|
16545
|
-
writer.writerow([])
|
16546
|
-
writer.writerow([f"Avg monthly NRR growth:", f"{avg_growth:.2f}%"])
|
16547
|
-
|
16548
16535
|
thumb = types.FSInputFile(os.path.join(EXTRA_D, "parse.jpg"))
|
16549
16536
|
await bot.send_document(chat_id=my_tid, document=types.FSInputFile(path), thumbnail=thumb)
|
16550
16537
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|