Mercurial > lbo > hg > analyrics
changeset 57:ad0625965942
Surface request tags in session log
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 22 Jul 2022 20:56:13 -0700 |
parents | 649097da34ae |
children | 2e5b0e49efe1 |
files | assets/index_dashboard.html.hbs src/logsdb.rs |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/assets/index_dashboard.html.hbs Fri Jul 22 19:31:57 2022 -0700 +++ b/assets/index_dashboard.html.hbs Fri Jul 22 20:56:13 2022 -0700 @@ -119,11 +119,11 @@ <div class="plotframe fullwidth">Recent Sessions <table align="center" id="sessionstable"> <tr> - <th>Start</th><th>Duration</th><th>Requests</th><th>Referer</th><th>Country/City</th><th>User Agent</th> + <th>Start</th><th>Duration</th><th>Requests</th><th>Tags</th><th>Referer</th><th>Country/City</th><th>User Agent</th> </tr> {{ #each recentSessions }} <tr> - <td>{{ start }}</td><td>{{ duration }}</td><td>{{ count }}</td><td>{{ refer }}</td><td>{{ origin_country }} {{ origin_city }}</td><td>{{ ua }}</td> + <td>{{ start }}</td><td>{{ duration }}</td><td>{{ count }}</td><td>{{ alltags }}</td><td>{{ refer }}</td><td>{{ origin_country }} {{ origin_city }}</td><td>{{ ua }}</td> </tr> {{ /each }} </table>
--- a/src/logsdb.rs Fri Jul 22 19:31:57 2022 -0700 +++ b/src/logsdb.rs Fri Jul 22 20:56:13 2022 -0700 @@ -11,6 +11,7 @@ use rocket_db_pools::{Connection, Database, Pool}; use sqlx::prelude::FromRow; +use std::collections::BTreeSet; use std::collections::HashMap; #[derive(Database)] @@ -37,6 +38,7 @@ origin_country: Option<String>, origin_city: Option<String>, ua: String, + alltags: String, } #[derive(Serialize)] @@ -49,6 +51,7 @@ origin_country: Option<String>, origin_city: Option<String>, ua: String, + alltags: String, } impl RecentSessionsTableRow { @@ -65,6 +68,10 @@ origin_country: r.origin_country, origin_city: r.origin_city, ua: r.ua, + alltags: BTreeSet::from_iter(r.alltags.split(",")) + .into_iter() + .collect::<Vec<&str>>() + .join(","), } } } @@ -416,9 +423,11 @@ RequestLog.Refer AS refer, Sessions.origin_country AS origin_country, Sessions.origin_city AS origin_city, - RequestLog.ua AS ua + RequestLog.ua AS ua, + GROUP_CONCAT(IIF(value, PRINTF("%s=%s", key, value), key)) AS alltags FROM RequestLog JOIN Sessions ON (RequestLog.session = Sessions.id) +JOIN RequestTags ON (RequestLog.id = RequestTags.requestid) WHERE Sessions.is_bot <= ? GROUP BY Sessions.id ORDER BY Sessions.start DESC, RequestLog.atime DESC