Compare commits
No commits in common. "d596fe9af795677b8506a517b2c3d9b902d832e4" and "8d12efb902f50356696bbf88cc45c66d1c36398d" have entirely different histories.
d596fe9af7
...
8d12efb902
56
exporto.py
56
exporto.py
@ -1,56 +0,0 @@
|
|||||||
from sqlalchemy import create_engine, Integer, String, BIGINT, Column, DateTime
|
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
|
||||||
from sqlalchemy.orm import sessionmaker
|
|
||||||
from sqlalchemy import select, update
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from flask import Flask
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
engine = create_engine('postgresql+psycopg2://postgres:postgres@postgres.vdk2ch.ru:5432/jack_bot', echo=True)
|
|
||||||
Session = sessionmaker(bind=engine)
|
|
||||||
|
|
||||||
|
|
||||||
Base = declarative_base()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class user(Base):
|
|
||||||
__tablename__ = 'users'
|
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
|
||||||
user_id = Column(Integer)
|
|
||||||
user_fullname = Column(String)
|
|
||||||
dick_size = (Column(Integer))
|
|
||||||
datetimes = (Column(DateTime))
|
|
||||||
chat_id = Column(BIGINT)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_top_dicks():
|
|
||||||
|
|
||||||
|
|
||||||
session = Session()
|
|
||||||
|
|
||||||
top = session.query(user.user_fullname, user.dick_size, user.user_id, user.chat_id).all()
|
|
||||||
|
|
||||||
|
|
||||||
session.close()
|
|
||||||
|
|
||||||
return top
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/metrics')
|
|
||||||
def metrics():
|
|
||||||
metrics = ""
|
|
||||||
for dick in get_top_dicks():
|
|
||||||
metrics += 'pipisio{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], dick[1])
|
|
||||||
return metrics
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(host='0.0.0.0', port=9992)
|
|
||||||
engine.dispose()
|
|
Loading…
Reference in New Issue
Block a user