initial steps towards fetch tracking
This commit is contained in:
parent
307d23e3d2
commit
797685377d
|
@ -12,6 +12,7 @@ create table doovers(dooverid integer primary key, dt text, tries integer, useri
|
||||||
create table onts (ontology text, honkid integer);
|
create table onts (ontology text, honkid integer);
|
||||||
create table honkmeta (honkid integer, genus text, json text);
|
create table honkmeta (honkid integer, genus text, json text);
|
||||||
create table hfcs (hfcsid integer primary key, userid integer, json text);
|
create table hfcs (hfcsid integer primary key, userid integer, json text);
|
||||||
|
create table tracks (xid text, fetches text);
|
||||||
|
|
||||||
create index idx_honksxid on honks(xid);
|
create index idx_honksxid on honks(xid);
|
||||||
create index idx_honksconvoy on honks(convoy);
|
create index idx_honksconvoy on honks(convoy);
|
||||||
|
@ -26,6 +27,7 @@ create index idx_ontology on onts(ontology);
|
||||||
create index idx_onthonkid on onts(honkid);
|
create index idx_onthonkid on onts(honkid);
|
||||||
create index idx_honkmetaid on honkmeta(honkid);
|
create index idx_honkmetaid on honkmeta(honkid);
|
||||||
create index idx_hfcsuser on hfcs(userid);
|
create index idx_hfcsuser on hfcs(userid);
|
||||||
|
create index idx_trackhonkid on tracks(xid);
|
||||||
|
|
||||||
create table config (key text, value text);
|
create table config (key text, value text);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ create table doovers(dooverid integer primary key, dt text, tries integer, useri
|
||||||
create table onts (ontology text, honkid integer);
|
create table onts (ontology text, honkid integer);
|
||||||
create table honkmeta (honkid integer, genus text, json text);
|
create table honkmeta (honkid integer, genus text, json text);
|
||||||
create table hfcs (hfcsid integer primary key, userid integer, json text);
|
create table hfcs (hfcsid integer primary key, userid integer, json text);
|
||||||
|
create table tracks (xid text, fetches text);
|
||||||
|
|
||||||
create index idx_honksxid on honks(xid);
|
create index idx_honksxid on honks(xid);
|
||||||
create index idx_honksconvoy on honks(convoy);
|
create index idx_honksconvoy on honks(convoy);
|
||||||
|
@ -23,6 +24,7 @@ create index idx_ontology on onts(ontology);
|
||||||
create index idx_onthonkid on onts(honkid);
|
create index idx_onthonkid on onts(honkid);
|
||||||
create index idx_honkmetaid on honkmeta(honkid);
|
create index idx_honkmetaid on honkmeta(honkid);
|
||||||
create index idx_hfcsuser on hfcs(userid);
|
create index idx_hfcsuser on hfcs(userid);
|
||||||
|
create index idx_trackhonkid on tracks(xid);
|
||||||
|
|
||||||
create table config (key text, value text);
|
create table config (key text, value text);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var myVersion = 31
|
var myVersion = 32
|
||||||
|
|
||||||
func doordie(db *sql.DB, s string, args ...interface{}) {
|
func doordie(db *sql.DB, s string, args ...interface{}) {
|
||||||
_, err := db.Exec(s, args...)
|
_, err := db.Exec(s, args...)
|
||||||
|
@ -351,6 +351,11 @@ func upgradedb() {
|
||||||
doordie(db, "update config set value = 31 where key = 'dbversion'")
|
doordie(db, "update config set value = 31 where key = 'dbversion'")
|
||||||
fallthrough
|
fallthrough
|
||||||
case 31:
|
case 31:
|
||||||
|
doordie(db, "create table tracks (xid text, fetches text)")
|
||||||
|
doordie(db, "create index idx_trackhonkid on tracks(xid)")
|
||||||
|
doordie(db, "update config set value = 32 where key = 'dbversion'")
|
||||||
|
fallthrough
|
||||||
|
case 32:
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Fatalf("can't upgrade unknown version %d", dbversion)
|
log.Fatalf("can't upgrade unknown version %d", dbversion)
|
||||||
|
|
9
web.go
9
web.go
|
@ -854,6 +854,14 @@ func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trackback(xid string, r *http.Request) {
|
||||||
|
agent := r.UserAgent()
|
||||||
|
who := originate(agent)
|
||||||
|
sig := r.Header.Get("Signature")
|
||||||
|
|
||||||
|
log.Printf("(%s) fetched %s (%s)", who, xid, sig)
|
||||||
|
}
|
||||||
|
|
||||||
func showonehonk(w http.ResponseWriter, r *http.Request) {
|
func showonehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
name := mux.Vars(r)["name"]
|
name := mux.Vars(r)["name"]
|
||||||
user, err := butwhatabout(name)
|
user, err := butwhatabout(name)
|
||||||
|
@ -870,6 +878,7 @@ func showonehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
if friendorfoe(r.Header.Get("Accept")) {
|
if friendorfoe(r.Header.Get("Accept")) {
|
||||||
j, ok := gimmejonk(xid)
|
j, ok := gimmejonk(xid)
|
||||||
if ok {
|
if ok {
|
||||||
|
trackback(xid, r)
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue