yeref 0.24.67__py3-none-any.whl → 0.24.68__py3-none-any.whl
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/yeref.py
CHANGED
@@ -16238,9 +16238,6 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16238
16238
|
sql = 'SELECT USER_TID, USER_VARS, USER_LSTS FROM "USER"'
|
16239
16239
|
data_users = await db_select_pg(sql, (), BASE_P)
|
16240
16240
|
|
16241
|
-
cohorts = defaultdict(set)
|
16242
|
-
activity_months = defaultdict(set)
|
16243
|
-
|
16244
16241
|
months = ["2025-06", "2025-07", "2025-08", "2025-09"]
|
16245
16242
|
data_users = []
|
16246
16243
|
for _ in range(20):
|
@@ -16305,6 +16302,10 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16305
16302
|
))
|
16306
16303
|
print(f"gen {data_users=}")
|
16307
16304
|
|
16305
|
+
|
16306
|
+
cohorts = defaultdict(set)
|
16307
|
+
activity_months = defaultdict(set)
|
16308
|
+
|
16308
16309
|
for USER_TID, USER_VARS, USER_LSTS in data_users:
|
16309
16310
|
USER_VARS = json.loads(USER_VARS or "{}")
|
16310
16311
|
USER_LSTS = json.loads(USER_LSTS or "{}")
|
@@ -16325,6 +16326,7 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16325
16326
|
pass
|
16326
16327
|
|
16327
16328
|
cohort_months = sorted(cohorts.keys())
|
16329
|
+
num_months = len(cohort_months)
|
16328
16330
|
|
16329
16331
|
def add_months(mo_str, n):
|
16330
16332
|
y, m = map(int, mo_str.split("-"))
|
@@ -16333,7 +16335,7 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16333
16335
|
new_m = (total - 1) % 12 + 1
|
16334
16336
|
return f"{new_y:04d}-{new_m:02d}"
|
16335
16337
|
|
16336
|
-
|
16338
|
+
# Собираем таблицу посменно по календарным месяцам
|
16337
16339
|
table = []
|
16338
16340
|
header = ["Месяц/Когорта"]
|
16339
16341
|
for mo in cohort_months:
|
@@ -16341,40 +16343,44 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16341
16343
|
header.append("∑")
|
16342
16344
|
table.append(header)
|
16343
16345
|
|
16344
|
-
#
|
16345
|
-
for
|
16346
|
+
# Матрица для подсчёта retention (counts[i][j] = активных из когорты j в календарном месяце i)
|
16347
|
+
counts = [[0] * num_months for _ in range(num_months)]
|
16348
|
+
for i in range(num_months):
|
16349
|
+
calendar_mo = cohort_months[i]
|
16346
16350
|
row = [f"M{i+1}"]
|
16347
16351
|
row_sum = 0
|
16348
|
-
|
16349
|
-
|
16350
|
-
if
|
16352
|
+
|
16353
|
+
for j in range(num_months):
|
16354
|
+
if j > i:
|
16355
|
+
row.append("")
|
16356
|
+
continue
|
16357
|
+
|
16358
|
+
cohort_mo = cohort_months[j]
|
16359
|
+
if i == j:
|
16360
|
+
# первый месяц когорты
|
16351
16361
|
val = len(cohorts[cohort_mo])
|
16352
16362
|
else:
|
16353
|
-
|
16354
|
-
val =
|
16363
|
+
# считаем, сколько из когорты j активны в календарном месяце i
|
16364
|
+
val = sum(1 for uid in cohorts[cohort_mo] if calendar_mo in activity_months.get(uid, set()))
|
16365
|
+
|
16366
|
+
counts[i][j] = val
|
16355
16367
|
if val:
|
16356
16368
|
row.append(str(val))
|
16357
16369
|
row_sum += val
|
16358
16370
|
else:
|
16359
16371
|
row.append("")
|
16372
|
+
|
16360
16373
|
row.append(str(row_sum))
|
16361
16374
|
table.append(row)
|
16362
16375
|
|
16363
|
-
# Считаем
|
16376
|
+
# Считаем средний ежемесячный churn
|
16364
16377
|
total_lost = 0
|
16365
16378
|
total_start = 0
|
16366
|
-
for
|
16367
|
-
|
16368
|
-
for i in range(
|
16369
|
-
|
16370
|
-
|
16371
|
-
count = len(cohorts[cohort_mo])
|
16372
|
-
else:
|
16373
|
-
count = sum(1 for uid in cohorts[cohort_mo] if target_mo in activity_months.get(uid, set()))
|
16374
|
-
counts.append(count)
|
16375
|
-
for k in range(len(counts) - 1):
|
16376
|
-
start_cnt = counts[k]
|
16377
|
-
next_cnt = counts[k + 1]
|
16379
|
+
for j in range(num_months):
|
16380
|
+
# для каждой когорты собираем по календарным месяцам
|
16381
|
+
for i in range(j, num_months - 1):
|
16382
|
+
start_cnt = counts[i][j]
|
16383
|
+
next_cnt = counts[i + 1][j]
|
16378
16384
|
if start_cnt > 0:
|
16379
16385
|
lost = start_cnt - next_cnt
|
16380
16386
|
total_lost += lost
|
@@ -16398,6 +16404,7 @@ async def return_cohort_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
|
16398
16404
|
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
16399
16405
|
|
16400
16406
|
|
16407
|
+
|
16401
16408
|
async def return_retention_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
|
16402
16409
|
try:
|
16403
16410
|
sql = 'SELECT USER_TID, USER_VARS, USER_LSTS FROM "USER"'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
|
2
|
+
yeref/l_.py,sha256=LMX_olmJwq-tgoALJCnhV_fGrL_i_43yBLkLIcEVqGo,1176743
|
3
|
+
yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
|
4
|
+
yeref/yeref.py,sha256=wj8Ry-Kst9NVBxFartZ_KiD8jV8vnI-vaXcd8gxCypE,1053269
|
5
|
+
yeref-0.24.68.dist-info/METADATA,sha256=AXFOBvqFgt55P4tLo-orKHy9TKtWq80UTwiOZGbzyQk,119
|
6
|
+
yeref-0.24.68.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
yeref-0.24.68.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
|
8
|
+
yeref-0.24.68.dist-info/RECORD,,
|
yeref-0.24.67.dist-info/RECORD
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
|
2
|
-
yeref/l_.py,sha256=LMX_olmJwq-tgoALJCnhV_fGrL_i_43yBLkLIcEVqGo,1176743
|
3
|
-
yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
|
4
|
-
yeref/yeref.py,sha256=rVaQc_Ol1gmoBs8HxywCSu--0yxBYRZzgDiNAp6MGE8,1052940
|
5
|
-
yeref-0.24.67.dist-info/METADATA,sha256=0Knh7gq-jz47tplBHpMdEYsEPZogwk3Wf1Bg6BXAQrA,119
|
6
|
-
yeref-0.24.67.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
yeref-0.24.67.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
|
8
|
-
yeref-0.24.67.dist-info/RECORD,,
|
File without changes
|
File without changes
|