organize onts better
This commit is contained in:
parent
49a5b2ca8b
commit
39ff5b5aa8
|
@ -610,7 +610,7 @@ var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt
|
||||||
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt
|
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt
|
||||||
var stmtThumbBiters, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
var stmtThumbBiters, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt
|
||||||
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
||||||
var stmtSelectOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
||||||
var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt
|
var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt
|
||||||
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt
|
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ func prepareStatements(db *sql.DB) {
|
||||||
stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
|
stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100")
|
||||||
stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?")
|
stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?")
|
||||||
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?")
|
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?")
|
||||||
stmtSelectOnts = preparetodie(db, "select distinct(ontology) from onts join honks on onts.honkid = honks.honkid where (honks.userid = ? or honks.whofore = 2)")
|
stmtAllOnts = preparetodie(db, "select ontology, count(ontology) from onts join honks on onts.honkid = honks.honkid where (honks.userid = ? or honks.whofore = 2) group by ontology")
|
||||||
stmtGetFilters = preparetodie(db, "select hfcsid, json from hfcs where userid = ?")
|
stmtGetFilters = preparetodie(db, "select hfcsid, json from hfcs where userid = ?")
|
||||||
stmtSaveFilter = preparetodie(db, "insert into hfcs (userid, json) values (?, ?)")
|
stmtSaveFilter = preparetodie(db, "insert into hfcs (userid, json) values (?, ?)")
|
||||||
stmtDeleteFilter = preparetodie(db, "delete from hfcs where userid = ? and hfcsid = ?")
|
stmtDeleteFilter = preparetodie(db, "delete from hfcs where userid = ? and hfcsid = ?")
|
||||||
|
|
|
@ -2,9 +2,15 @@
|
||||||
<main>
|
<main>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<p>ontologies of interest
|
<p>ontologies of interest
|
||||||
<p>
|
{{ $letter := 0 }}
|
||||||
|
<ul>
|
||||||
{{ range .Onts }}
|
{{ range .Onts }}
|
||||||
<a href="/o/{{ index . 1 }}">{{ index . 0 }}</a>
|
{{ if not (eq $letter (index .Name 0)) }}
|
||||||
|
{{ $letter = (index .Name 0) }}
|
||||||
|
<li><p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<a href="/o/{{ .Name }}">#{{ .Name }}</a> ({{ .Count }})
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
19
web.go
19
web.go
|
@ -654,28 +654,37 @@ func showontology(w http.ResponseWriter, r *http.Request) {
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Ont struct {
|
||||||
|
Name string
|
||||||
|
Count int64
|
||||||
|
}
|
||||||
|
|
||||||
func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) {
|
func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) {
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
var userid int64 = -1
|
var userid int64 = -1
|
||||||
if u != nil {
|
if u != nil {
|
||||||
userid = u.UserID
|
userid = u.UserID
|
||||||
}
|
}
|
||||||
rows, err := stmtSelectOnts.Query(userid)
|
rows, err := stmtAllOnts.Query(userid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("selection error: %s", err)
|
log.Printf("selection error: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
var onts [][]string
|
var onts []Ont
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var o string
|
var o Ont
|
||||||
err := rows.Scan(&o)
|
err := rows.Scan(&o.Name, &o.Count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error scanning ont: %s", err)
|
log.Printf("error scanning ont: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
onts = append(onts, []string{o, o[1:]})
|
o.Name = o.Name[1:]
|
||||||
|
onts = append(onts, o)
|
||||||
}
|
}
|
||||||
|
sort.Slice(onts, func(i, j int) bool {
|
||||||
|
return onts[i].Name < onts[j].Name
|
||||||
|
})
|
||||||
if u == nil {
|
if u == nil {
|
||||||
w.Header().Set("Cache-Control", "max-age=300")
|
w.Header().Set("Cache-Control", "max-age=300")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue