aboutsummaryrefslogtreecommitdiffstats
path: root/webstats/queries.sql
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2025-02-09 13:48:57 +0100
committerOscar Najera <hi@oscarnajera.com>2025-02-09 13:48:57 +0100
commit050efc586b961f46f6e917cb8e4f522234f975cc (patch)
treef25d00c55531ae021541fa567b3d1743d81c1524 /webstats/queries.sql
parent2b156c210a42631678a5798ceeb84eb382d33b21 (diff)
downloadscratch-050efc586b961f46f6e917cb8e4f522234f975cc.tar.gz
scratch-050efc586b961f46f6e917cb8e4f522234f975cc.tar.bz2
scratch-050efc586b961f46f6e917cb8e4f522234f975cc.zip
little draft on visit stats
Diffstat (limited to 'webstats/queries.sql')
-rw-r--r--webstats/queries.sql21
1 files changed, 21 insertions, 0 deletions
diff --git a/webstats/queries.sql b/webstats/queries.sql
new file mode 100644
index 0000000..2a3f762
--- /dev/null
+++ b/webstats/queries.sql
@@ -0,0 +1,21 @@
+#lang cl-yesql/sqlite
+
+-- name: create-stats-table
+-- Creates table for tracking visits
+CREATE TABLE IF NOT EXISTS STATS (
+ timestamp int DEFAULT (unixepoch()) NOT NULL,
+ click text,
+ page text,
+ referrer text,
+ ip text,
+ user_agent text,
+ title text)
+
+-- name: drop-stats-table
+-- Removes table tracking visits
+DROP TABLE IF EXISTS STATS
+
+-- name: insert @last-id
+-- Insert a data point
+INSERT INTO STATS (click, page, referrer, ip, user_agent, title)
+ VALUES (:click, :page, :referer, :ip, :user_agent, :title)