mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-11-26 04:52:43 +00:00
Created a few helper scripts to dump some refined analytics
This commit is contained in:
27
analytics/queries/visits.js
Normal file
27
analytics/queries/visits.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const path = require('path');
|
||||
const { open: opensql } = require('sqlite');
|
||||
const sqlite3 = require('sqlite3');
|
||||
const sql = require('../sql-tag');
|
||||
|
||||
(async () => {
|
||||
// open the database
|
||||
const db = await opensql({
|
||||
filename: path.resolve(__dirname, '..', 'database.sqlite'),
|
||||
driver: sqlite3.Database,
|
||||
});
|
||||
|
||||
const rows = await db.all(sql`
|
||||
SELECT
|
||||
date(dts) as day,
|
||||
count(DISTINCT IFNULL(tid, ip)) as tids
|
||||
FROM records
|
||||
WHERE date(dts) > date('now', '-12 month')
|
||||
GROUP BY date(dts);
|
||||
`);
|
||||
|
||||
// console.table(results);
|
||||
for (const { day, tids } of rows) {
|
||||
process.stdout.write(day + '\t' + tids + '\n');
|
||||
}
|
||||
|
||||
})().catch(console.error);
|
||||
Reference in New Issue
Block a user