Skip to content

Instantly share code, notes, and snippets.

def get_plot(data):
fig, axes = plt.subplots(2, 2, figsize = (16 , 10))
# fig.subtitle("Feed statistics for the previous 7 days")
plot_dict = {(0,0):{'y':'DAU', 'title': 'Unique users'},
(0,1):{'y':'likes', 'title': 'Likes'},
(1,0):{'y':'views', 'title': 'Views'},
(1,1):{'y':'CTR', 'title': 'CTR'}}
for i in range(2):
def feed_report(chat=None):
chat = chat or chat_id
bot = telegram.Bot(token=my_token)
msg = """ 📃Feed report for {date}📃
Events: {events}
🧑DAU: {users}({to_users_day_ago:+.2%} to day ago, {to_users_week_ago:+.2%} to week ago)
👍Likes: {likes}({to_likes_day_ago:+.2%} to day ago, {to_likes_week_ago:+.2%} to week ago)
👀Views: {views}({to_views_day_ago:+.2%} to day ago, {to_views_week_ago:+.2%} to week ago)
🌈CTR: {ctr}({to_ctr_day_ago:+.2%} to day ago, {to_ctr_week_ago:+.2%} to week ago)
"""
def feed_report(chat=None):
chat = chat or chat_id
bot = telegram.Bot(token=my_token)
msg = """ 📃Feed report for {data}📃
Events: {events}
🧑DAU: {users}({to_users_day_ago:+.2%} to day ago, {to_users_week_ago:+.2%} to week ago)
👍Likes: {liked}({to_likes_day_ago:+.2%} to day ago, {to_likes_week_ago:+.2%} to week ago)
👀Views: {views}({to_views_day_ago:+.2%} to day ago, {to_views_week_ago:+.2%} to week ago)
🌈CTR: {ctr}({to_ctr_day_ago:+.2%} to day ago, {to_ctr_week_ago:+.2%} to week ago)
"""
bot = telegram.Bot(token=os.environ.get("REPORT_BOT_TOKEN"))
image: cr.yandex/crp742p3qacifd2hcon2/practice-da:latest
stages:
- build
- test
- deploy
job_name:
stage: test
script:
job_name:
stage: test
script:
- echo 'test run script'
stages:
- build
- test
- deploy
data = Getch('select * from simulator.feed_actions where toDate(time) = today() limit 100').df
file_object = io.StringIO()
data.to_csv(file_object)
file_object.name = 'test_file.csv'
file_object.seek(0)
bot.sendDocument(chat_id=chat_id, document = file_object)
x = np.arange(1, 10, 1)
y = np.random.choice(5, len(x))
sns.lineplot(x, y)
plt.title('test plot')
plot_object = io.BytesIO()
plt.savefig(plot_object)
plot_object.seek(0)
plot_object.name = 'test_plot.png'
plt.close()
bot.sendPhoto(chat_id=chat_id, photo = plot_object)
chat_id = -1001592565485
msg = 'Hello'
bot.sendMessage(chat_id = chat_id, text = msg)