This commit is contained in:
parent
c5104e0550
commit
cbb2d5de99
31
exporto.py
31
exporto.py
@ -36,19 +36,44 @@ def get_top_dicks():
|
||||
|
||||
session = Session()
|
||||
|
||||
top = session.query(user.user_fullname, user.dick_size, user.user_id, user.chat_id).all()
|
||||
top = session.query(user.user_fullname, user.dick_size, user.user_id, user.chat_id).order_by(user.dick_size.desc()).all()
|
||||
|
||||
|
||||
session.close()
|
||||
|
||||
return top
|
||||
|
||||
|
||||
|
||||
@app.route('/metrics')
|
||||
def metrics():
|
||||
metrics = ""
|
||||
for dick in get_top_dicks():
|
||||
|
||||
docks = get_top_dicks()
|
||||
|
||||
# текущий размер пипис
|
||||
for dick in docks:
|
||||
metrics += 'pipisio{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], dick[1])
|
||||
|
||||
# расстояние до следующего впереди
|
||||
for k in range(len(docks)):
|
||||
|
||||
### не самый красивый код для не самой красивой ситуации
|
||||
|
||||
if k == 0:
|
||||
metrics += 'pipisio_topdick_distanso{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], 0)
|
||||
else:
|
||||
|
||||
i = k - 1
|
||||
upper_dick_size = docks[i][1]
|
||||
while i > 0 and upper_dick_size == docks[k][1]:
|
||||
i -= 1
|
||||
upper_dick_size = docks[i][1]
|
||||
|
||||
if i == 0:
|
||||
metrics += 'pipisio_topdick_distanso{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], 0)
|
||||
else:
|
||||
metrics += 'pipisio_topdick_distanso{user="%s", user_id="%s", chat_id="%s"} %s\n' % (dick[0], dick[2], dick[3], (upper_dick_size - docks[k][1]))
|
||||
|
||||
return metrics
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user