yeref 0.24.40__tar.gz → 0.24.42__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.40
3
+ Version: 0.24.42
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.40',
5
+ version='0.24.42',
6
6
  description='desc-f',
7
7
  author='john smith',
8
8
  packages=['yeref'],
@@ -15944,6 +15944,7 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
15944
15944
  "mau": 0,
15945
15945
  "wallets": 0,
15946
15946
  "tx": 0,
15947
+ "pay": 0,
15947
15948
  "tvl": 0,
15948
15949
  "/start": 0,
15949
15950
  "/startapp": 0
@@ -15954,6 +15955,76 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
15954
15955
  users_set = set()
15955
15956
 
15956
15957
  def process_user_rows(rows):
15958
+ # months = ["2025-06", "2025-07", "2025-08", "2025-09"]
15959
+ # data_users = []
15960
+ # for _ in range(3):
15961
+ # # дата входа
15962
+ # entry_month = random.choice(months)
15963
+ # entry_day = random.randint(1, 28)
15964
+ # entry_date = f"{entry_month}-{entry_day:02}"
15965
+ # entry_dt_obj = datetime.strptime(entry_date, '%Y-%m-%d')
15966
+ # entry_dt = f"{entry_dt_obj.strftime('%d-%m-%Y')}_{datetime.now().strftime('%H-%M-%S')}"
15967
+ # utm = random.choice(["/start", "/startapp"])
15968
+ #
15969
+ # # месяцы от входа и дальше
15970
+ # valid_months = [m for m in months if datetime.strptime(m + "-01", "%Y-%m-%d") >= entry_dt_obj.replace(day=1)]
15971
+ # if not valid_months:
15972
+ # valid_months = [entry_month]
15973
+ #
15974
+ # user_mau = sorted(random.sample(valid_months, k=random.randint(1, len(valid_months))))
15975
+ # user_dau_dates = set()
15976
+ # txs, payments = [], []
15977
+ #
15978
+ # # транзакция
15979
+ # if user_mau and random.random() < 0.5:
15980
+ # tx_month = random.choice(user_mau)
15981
+ # tx_day = random.randint(1, 28)
15982
+ # tx_date = f"{tx_month}-{tx_day:02}"
15983
+ # dt_tx = datetime.strptime(tx_date, "%Y-%m-%d")
15984
+ # if dt_tx >= entry_dt_obj:
15985
+ # txs = [{
15986
+ # "TYPE": random.choice(["don", "sub", "pst"]),
15987
+ # "AMOUNT": str(random.randint(1, 10)),
15988
+ # "ADDRESS": f"address{random.randint(1, 999)}",
15989
+ # "DT_START": f"{dt_tx.strftime('%d-%m-%Y')}_12-00-00",
15990
+ # }]
15991
+ # user_dau_dates.add(tx_date)
15992
+ #
15993
+ # # платеж
15994
+ # if user_mau and random.random() < 0.5:
15995
+ # pay_month = random.choice(user_mau)
15996
+ # pay_day = random.randint(1, 28)
15997
+ # pay_date = f"{pay_month}-{pay_day:02}"
15998
+ # dt_pay = datetime.strptime(pay_date, "%Y-%m-%d")
15999
+ # if dt_pay >= entry_dt_obj:
16000
+ # payments = [{
16001
+ # "TYPE": random.choice(["don", "sub", "pst"]),
16002
+ # "DT_START": f"{dt_pay.strftime('%d-%m-%Y')}_14-00-00",
16003
+ # "DT_END": "0",
16004
+ # "AMOUNT": str(random.randint(1, 10))
16005
+ # }]
16006
+ # user_dau_dates.add(pay_date)
16007
+ #
16008
+ # # вход в приложение
16009
+ # user_dau_dates.add(entry_date)
16010
+ #
16011
+ # # остальные посещения
16012
+ # for m in user_mau:
16013
+ # day = random.randint(1, 28)
16014
+ # visit = f"{m}-{day:02}"
16015
+ # dt_visit = datetime.strptime(visit, "%Y-%m-%d")
16016
+ # if dt_visit >= entry_dt_obj and random.random() < 0.7:
16017
+ # user_dau_dates.add(visit)
16018
+ #
16019
+ # user_dau = sorted(user_dau_dates)
16020
+ # wallet = f"wallet{random.randint(1, 100)}" if txs else random.choice([f"wallet{random.randint(1, 100)}", ""])
16021
+ #
16022
+ # data_users.append((
16023
+ # random.randint(100000, 999999),
16024
+ # json.dumps({"USER_WALLET": wallet, "USER_UTM": utm, "USER_DT": entry_dt}),
16025
+ # json.dumps({"USER_DAU": user_dau, "USER_MAU": user_mau, "USER_TXS": txs, "USER_PAYMENTS": payments})
16026
+ # ))
16027
+
15957
16028
  for USER_TID, USER_VARS, USER_LSTS in rows:
15958
16029
  USER_VARS = json.loads(USER_VARS or "{}")
15959
16030
  USER_LSTS = json.loads(USER_LSTS or "{}")
@@ -15963,10 +16034,17 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
15963
16034
  USER_DAU = USER_LSTS.get("USER_DAU", [])
15964
16035
  USER_MAU = USER_LSTS.get("USER_MAU", [])
15965
16036
  USER_TXS = USER_LSTS.get("USER_TXS", [])
16037
+ USER_PAYMENTS = USER_LSTS.get("USER_PAYMENTS", [])
15966
16038
  USER_STATUSES = USER_LSTS.get("USER_STATUSES", [])
15967
16039
 
15968
16040
  if USER_WALLET: wallets_set.add(USER_WALLET)
15969
- if not len(USER_STATUSES): users_set.add(USER_TID)
16041
+ if USER_STATUSES:
16042
+ last_status = max(USER_STATUSES, key=lambda x: list(x.values())[0])
16043
+ last_key = list(last_status.keys())[0]
16044
+ if last_key not in ['left', 'kicked']:
16045
+ users_set.add(USER_TID)
16046
+ else:
16047
+ users_set.add(USER_TID)
15970
16048
 
15971
16049
  for day_str in USER_DAU:
15972
16050
  dt_day = datetime.strptime(day_str, "%Y-%m-%d")
@@ -15984,13 +16062,16 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
15984
16062
  if USER_WALLET:
15985
16063
  metrics_by_month[month_key]["wallets"] += 1
15986
16064
 
15987
- for tx in USER_TXS:
15988
- dt_start = tx.get("DT_START", "")
15989
- amount = int(tx.get("AMOUNT", "0"))
15990
- dt_tx = datetime.strptime(dt_start, "%d-%m-%Y_%H-%M-%S")
15991
- month_key = dt_tx.strftime("%Y-%m")
15992
- metrics_by_month[month_key]["tx"] += 1
15993
- metrics_by_month[month_key]["tvl"] += amount
16065
+ # for tx in USER_TXS:
16066
+ # dt_start = tx.get("DT_START", "")
16067
+ # amount = int(tx.get("AMOUNT", "0"))
16068
+ # dt_tx = datetime.strptime(dt_start, "%d-%m-%Y_%H-%M-%S")
16069
+ # month_key = dt_tx.strftime("%Y-%m")
16070
+ # metrics_by_month[month_key]["tx"] += 1
16071
+ # metrics_by_month[month_key]["tvl"] += amount
16072
+
16073
+ metrics_by_month[month_key]["tx"] += len(USER_TXS)
16074
+ metrics_by_month[month_key]["pay"] += len(USER_PAYMENTS)
15994
16075
 
15995
16076
  if USER_DT:
15996
16077
  dt_obj = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S")
@@ -16002,17 +16083,19 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
16002
16083
  ENT_TID = item[0]
16003
16084
  sql = f'SELECT USER_TID, USER_VARS, USER_LSTS FROM {schema_name}_{ENT_TID}.USER'
16004
16085
  data_users = await db_select_pg(sql, (), BASE_P)
16086
+ print(f"{data_users=}")
16005
16087
  process_user_rows(data_users)
16006
16088
 
16007
16089
  sql = f"SELECT USER_TID, USER_VARS, USER_LSTS FROM \"USER\""
16008
16090
  data_users = await db_select_pg(sql, (), BASE_P)
16091
+ print(f"{data_users=}")
16009
16092
  process_user_rows(data_users)
16010
16093
 
16011
16094
  all_months = sorted(metrics_by_month.keys())
16012
16095
  f_name = os.path.join(EXTRA_D, "1_metrics.csv")
16013
16096
  with open(f_name, mode="w", encoding="utf-8", newline="") as csvfile:
16014
16097
  writer = csv.writer(csvfile, delimiter=',')
16015
- writer.writerow(["MO", "DAU", "MAU", "Wallets", "Transactions", "TVL", "/start", "/startapp"])
16098
+ writer.writerow(["MO", "DAU", "MAU", "Wallets", "TX Count", "PAY Count", "/start", "/startapp", "TVL"])
16016
16099
  for ym in all_months:
16017
16100
  row = [
16018
16101
  ym,
@@ -16020,9 +16103,10 @@ async def return_view_metrics(bot, PROJECT_USERNAME, EXTRA_D, BASE_P):
16020
16103
  metrics_by_month[ym]["mau"],
16021
16104
  metrics_by_month[ym]["wallets"],
16022
16105
  metrics_by_month[ym]["tx"],
16023
- "",
16106
+ metrics_by_month[ym]["pay"],
16024
16107
  metrics_by_month[ym]["/start"],
16025
16108
  metrics_by_month[ym]["/startapp"],
16109
+ "",
16026
16110
  ]
16027
16111
  writer.writerow(row)
16028
16112
  csvfile.write("\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.24.40
3
+ Version: 0.24.42
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