Não é construído com SQL, mas tudo bem, podemos derivá-lo…
Aqui está o guia geral sobre Meta:
This is a reference guide for describing how the Admin Dashboard Reports function, the data they’re displaying, the corresponding Data Explorer SQL queries, and where to find the Ruby code for each report.
Required user level: Staff
Discourse contains several built-in admin dashboard Reports that can be useful for exploring stats about a community. To access these reports, you can visit discourse.example.com/admin/dashboard/reports on your site ( or click the…
Especificamente: discourse/app/models/concerns/reports/consolidated_page_views.rb at main · discourse/discourse · GitHub
É construído usando um Modelo Rails, ApplicationRequest , por exemplo.
[3] pry(main)> ApplicationRequest.last(10)
=> [#<ApplicationRequest:0x000055c8edcf99f8 id: 4798, date: Thu, 17 Nov 2022, req_type: "http_total", count: 3080>,
#<ApplicationRequest:0x000055c8edcf9ac0 id: 4799, date: Thu, 17 Nov 2022, req_type: "http_background", count: 1014>,
#<ApplicationRequest:0x000055c8edcf9bb0 id: 4800, date: Thu, 17 Nov 2022, req_type: "page_view_crawler", count: 539>,
#<ApplicationRequest:0x000055c8edcf9c78 id: 4801, date: Thu, 17 Nov 2022, req_type: "http_2xx", count: 1929>,
#<ApplicationRequest:0x000055c8edcf9d68 id: 4802, date: Thu, 17 Nov 2022, req_type: "http_4xx", count: 52>,
#<ApplicationRequest:0x000055c8edcf9e30 id: 4803, date: Thu, 17 Nov 2022, req_type: "http_3xx", count: 85>,
#<ApplicationRequest:0x000055c8edcf9f20 id: 4804, date: Thu, 17 Nov 2022, req_type: "page_view_anon", count: 40>,
#<ApplicationRequest:0x000055c8edcf9fe8 id: 4805, date: Thu, 17 Nov 2022, req_type: "page_view_logged_in", count: 148>,
#<ApplicationRequest:0x000055c8edcfa0d8 id: 4806, date: Thu, 17 Nov 2022, req_type: "page_view_logged_in_mobile", count: 134>,
#<ApplicationRequest:0x000055c8edd00a00 id: 4807, date: Thu, 17 Nov 2022, req_type: "page_view_anon_mobile", count: 2>]
A tabela correspondente que você precisa é application_requests (mas não a vejo exposta no Data Explorer , talvez eu tenha perdido?).
Os req_type(s) neste relatório são:
page_view_logged_in
page_view_anon
page_view_crawler
É uma soma regular e agrupamento, então, provavelmente, você poderia começar com o console Rails:
ApplicationRequest.where(req_type:["page_view_logged_in", "page_view_anon", "page_view_crawler"]).where('date BETWEEN ? AND ?', '11/14/2022', '11/17/2022')
por exemplo
ou o equivalente em SQL:
SELECT * FROM application_requests WHERE req_type IN (7, 8, 6) AND (date BETWEEN '11/14/2022' AND '11/17/2022')
Parte da agregação já foi feita para você, pois os dados estão em uma coluna de contagem.