Skip to content

Instantly share code, notes, and snippets.

query_feed_q = """
select
toDate(time) as date
,count(distinct user_id) as users_feed
,countIf(action='like') as likes
,countIf(action='view') as views
,countIf(action='like') / countIf(action='view') as CTR
,likes+views as events
from simulator_20220620.feed_actions
where toDate(time) between today() - 8 and today() - 1
@staticmethod
def today():
current_date = datetime.datetime.now()
return {'day': current_date.day,
'month': current_date.month,
'year': current_date.year,
'hour': current_date.hour,
'minute': current_date.minute,
'second': current_date.second}
@classmethod
def fill_date(clf):
current_date = clf.today()
Logger.day = current_date.day
Logger.month = current_date.month
Logger.year = current_date.year
Logger.hour = current_date.hour
Logger.minute = current_date.minute
Logger.second = current_date.second
import os
import datetime
msg = """ 📃Application report for {date}📃
Events: {events}
🧑DAU: {users}({to_users_day_ago:+.2%} to day ago, {to_users_week_ago:+.2%} to week ago)
🧑DAU by platform:
📱IOS: {users_ios}({to_users_ios_day_ago:+.2%} to day ago, {to_users_ios_week_ago:+.2%} to week ago)
📞Android: {users_and}({to_users_and_day_ago:+.2%} to day ago, {to_users_and_week_ago:+.2%} to week ago)
👫DAU by gender:
🙎Male: {users_male}({to_users_male_day_ago:+.2%} to day ago, {to_users_male_week_ago:+.2%} to week ago)
👰‍Female: {users_female}({to_users_female_day_ago:+.2%} to day ago, {to_users_female_week_ago:+.2%} to week ago)
🧑New users: {new_users}({to_new_users_day_ago:+.2%} to day ago, {to_new_users_week_ago:+.2%} to week ago)
import os
import telegram
import pandahouse as ph
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import io
import pandas as pd
sns.set()
image: cr.yandex/crp742p3qacifd2hcon2/practice-da:latest
stages:
- init
- run
feed_report_job:
stage: run
script:
image: cr.yandex/crp742p3qacifd2hcon2/practice-da:latest
bot = telegram.Bot(token=os.environ.get("REPORT_BOT_TOKEN"))
plot_object = get_plot(data)
bot.sendPhoto(chat_id=chat_id, photo=plot_object)