mirror of
https://github.com/house-of-vanity/libopenanal.git
synced 2025-07-06 21:24:08 +00:00
Messages count per char.
This commit is contained in:
24
database.py
24
database.py
@ -141,17 +141,35 @@ class DataBase:
|
||||
""" % user_id)
|
||||
chats = self.execute("""SELECT c.title,
|
||||
count(c.id) count,
|
||||
min(date(r.date, 'unixepoch'))
|
||||
min(date(r.date, 'unixepoch')),
|
||||
m.messages
|
||||
FROM `relations` r
|
||||
LEFT JOIN `user` u ON u.id = r.user_id
|
||||
LEFT JOIN `conf` c ON c.id = r.conf_id
|
||||
LEFT JOIN (
|
||||
SELECT COUNT(messages) as messages, title FROM (
|
||||
SELECT COUNT(r.date) AS messages, c.title
|
||||
FROM `relations` r
|
||||
LEFT JOIN `conf` c ON c.id = r.conf_id
|
||||
WHERE user_id = %s
|
||||
GROUP BY c.title, r.date
|
||||
) GROUP BY title
|
||||
) m ON c.title = m.title
|
||||
WHERE u.id = %s
|
||||
GROUP BY c.id""" % user_id)
|
||||
GROUP BY c.id""" % (user_id, user_id))
|
||||
|
||||
avg_lenght = self.execute("""
|
||||
SELECT count(date) as words
|
||||
FROM `relations`
|
||||
WHERE user_id = %s
|
||||
GROUP BY date""" % user_id)
|
||||
messages = self.execute("""
|
||||
SELECT count(*) FROM(
|
||||
SELECT count(date) as words
|
||||
FROM `relations`
|
||||
WHERE user_id = %s
|
||||
GROUP BY date
|
||||
)""" % user_id)
|
||||
avg = 0
|
||||
for i in avg_lenght:
|
||||
avg += i[0]
|
||||
@ -170,10 +188,12 @@ class DataBase:
|
||||
'first_date': raw1[4],
|
||||
'word_count': raw1[5],
|
||||
'last_message': raw1[6],
|
||||
'messages': messages[0][0],
|
||||
'day_known': day_known,
|
||||
'top': top,
|
||||
'chats': chats,
|
||||
'avg': avg,
|
||||
|
||||
}
|
||||
return user_info
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
<b>Last message: </b>{{ user_info.last_message }}<br>
|
||||
<b>Days known: </b>{{ user_info.day_known }}<br>
|
||||
<b>Word said: </b>{{ user_info.word_count }}<br>
|
||||
<b>Messages sent: </b>{{ user_info.messages }}<br>
|
||||
<b>Words per day: </b>{{ '%0.2f'| format((user_info.word_count / user_info.day_known)|float) }}<br>
|
||||
<b>Words per message: </b>~{{ '%0.2f'| format(user_info.avg|float) }}<br>
|
||||
</p>
|
||||
@ -95,7 +96,8 @@
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Chat</th>
|
||||
<th scope="col">Words said</th>
|
||||
<th scope="col">Words</th>
|
||||
<th scope="col">Messages</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -104,6 +106,7 @@
|
||||
<th scope="row">{{ loop.index }}</th>
|
||||
<td>{{ chat[0] }}</td>
|
||||
<td><span class="badge badge-secondary">{{ chat[1] }} </span></td>
|
||||
<td><span class="badge badge-secondary">{{ chat[3] }} </span></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
Reference in New Issue
Block a user