mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Beginn Personenansicht Beiträge / Anzahl Personenübersicht
This commit is contained in:
@@ -8,6 +8,7 @@ full_bin = "./tmp/musenalm --dir ./pb_data serve"
|
|||||||
cmd = "go build -tags=dev,fts5,sqlite_icu -o ./tmp/musenalm ."
|
cmd = "go build -tags=dev,fts5,sqlite_icu -o ./tmp/musenalm ."
|
||||||
delay = 400
|
delay = 400
|
||||||
exclude_dir = [
|
exclude_dir = [
|
||||||
|
"views/assets",
|
||||||
"views/transform",
|
"views/transform",
|
||||||
"views/routes",
|
"views/routes",
|
||||||
"views/layouts",
|
"views/layouts",
|
||||||
|
|||||||
@@ -290,3 +290,46 @@ func AgentsForOrg(app core.App, org bool, letter string) ([]*Agent, error) {
|
|||||||
|
|
||||||
return agents, nil
|
return agents, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AgentCount struct {
|
||||||
|
Count int `db:"count"`
|
||||||
|
ID string `db:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CountAgentsBaende(app core.App) (map[string]int, error) {
|
||||||
|
couns := []AgentCount{}
|
||||||
|
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, AGENTS_TABLE)).
|
||||||
|
Select("count(*) as count, " + AGENTS_TABLE + " as id").
|
||||||
|
GroupBy(AGENTS_TABLE).
|
||||||
|
All(&couns)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := make(map[string]int, len(couns))
|
||||||
|
for _, c := range couns {
|
||||||
|
ret[c.ID] = c.Count
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CountAgentsContents(app core.App) (map[string]int, error) {
|
||||||
|
couns := []AgentCount{}
|
||||||
|
err := app.RecordQuery(RelationTableName(CONTENTS_TABLE, AGENTS_TABLE)).
|
||||||
|
Select("count(*) as count, " + AGENTS_TABLE + " as id").
|
||||||
|
GroupBy(AGENTS_TABLE).
|
||||||
|
All(&couns)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := make(map[string]int, len(couns))
|
||||||
|
for _, c := range couns {
|
||||||
|
ret[c.ID] = c.Count
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ type AgentResult struct {
|
|||||||
CResult []*dbmodels.Entry /// Sorted
|
CResult []*dbmodels.Entry /// Sorted
|
||||||
Contents map[string][]*dbmodels.Content // KEY: entry ID
|
Contents map[string][]*dbmodels.Content // KEY: entry ID
|
||||||
ContentsAgents map[string][]*dbmodels.RContentsAgents // KEY: Content ID
|
ContentsAgents map[string][]*dbmodels.RContentsAgents // KEY: Content ID
|
||||||
|
Agents map[string]*dbmodels.Agent // KEY: Agent ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAgentResult(app core.App, id string) (*AgentResult, error) {
|
func NewAgentResult(app core.App, id string) (*AgentResult, error) {
|
||||||
@@ -79,6 +80,11 @@ func NewAgentResult(app core.App, id string) (*AgentResult, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = res.FilterContentsByEntry(app, id, res)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,9 +152,8 @@ func (p *AgentResult) FilterEntriesByPerson(app core.App, id string, res *AgentR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *AgentResult) FilterContentsByEntry(app core.App, id string, res *AgentResult) error {
|
func (p *AgentResult) FilterContentsByEntry(app core.App, id string, res *AgentResult) error {
|
||||||
// 1. DB Hit
|
|
||||||
relations, err := dbmodels.RContentsAgents_Agent(app, id)
|
relations, err := dbmodels.RContentsAgents_Agent(app, id)
|
||||||
if err != nil && err != sql.ErrNoRows {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,13 +163,24 @@ func (p *AgentResult) FilterContentsByEntry(app core.App, id string, res *AgentR
|
|||||||
|
|
||||||
contentsagents := make(map[string][]*dbmodels.RContentsAgents)
|
contentsagents := make(map[string][]*dbmodels.RContentsAgents)
|
||||||
contentIds := []any{}
|
contentIds := []any{}
|
||||||
|
agentids := []any{}
|
||||||
for _, r := range relations {
|
for _, r := range relations {
|
||||||
contentIds = append(contentIds, r.Content())
|
contentIds = append(contentIds, r.Content())
|
||||||
|
agentids = append(agentids, r.Agent())
|
||||||
contentsagents[r.Content()] = append(contentsagents[r.Content()], r)
|
contentsagents[r.Content()] = append(contentsagents[r.Content()], r)
|
||||||
}
|
}
|
||||||
res.ContentsAgents = contentsagents
|
res.ContentsAgents = contentsagents
|
||||||
|
|
||||||
// 2. DB Hit
|
agents, err := dbmodels.Agents_IDs(app, agentids)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
aMap := make(map[string]*dbmodels.Agent, len(agents))
|
||||||
|
for _, a := range agents {
|
||||||
|
aMap[a.Id] = a
|
||||||
|
}
|
||||||
|
res.Agents = aMap
|
||||||
|
|
||||||
contents, err := dbmodels.Contents_IDs(app, contentIds)
|
contents, err := dbmodels.Contents_IDs(app, contentIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -178,7 +194,6 @@ func (p *AgentResult) FilterContentsByEntry(app core.App, id string, res *AgentR
|
|||||||
}
|
}
|
||||||
res.Contents = contentMap
|
res.Contents = contentMap
|
||||||
|
|
||||||
// 3. DB Hit
|
|
||||||
entries, err := dbmodels.Entries_IDs(app, entrykeys)
|
entries, err := dbmodels.Entries_IDs(app, entrykeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -91,6 +91,16 @@ func (p *PersonenPage) FilterRequest(app core.App, engine *templating.Engine, e
|
|||||||
data["filter"] = filter
|
data["filter"] = filter
|
||||||
data["letter"] = letter
|
data["letter"] = letter
|
||||||
|
|
||||||
|
bcount, err := dbmodels.CountAgentsBaende(app)
|
||||||
|
if err == nil {
|
||||||
|
data["bcount"] = bcount
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err := dbmodels.CountAgentsContents(app)
|
||||||
|
if err == nil {
|
||||||
|
data["ccount"] = count
|
||||||
|
}
|
||||||
|
|
||||||
letters, err := dbmodels.LettersForAgents(app, filter)
|
letters, err := dbmodels.LettersForAgents(app, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return engine.Response404(e, err, data)
|
return engine.Response404(e, err, data)
|
||||||
@@ -132,6 +142,16 @@ func (p *PersonenPage) SearchRequest(app core.App, engine *templating.Engine, e
|
|||||||
data["agents"] = agents
|
data["agents"] = agents
|
||||||
data["altagents"] = altagents
|
data["altagents"] = altagents
|
||||||
|
|
||||||
|
bcount, err := dbmodels.CountAgentsBaende(app)
|
||||||
|
if err == nil {
|
||||||
|
data["bcount"] = bcount
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err := dbmodels.CountAgentsContents(app)
|
||||||
|
if err == nil {
|
||||||
|
data["ccount"] = count
|
||||||
|
}
|
||||||
|
|
||||||
return p.Get(e, engine, data)
|
return p.Get(e, engine, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
{{- $singleView = index . 4 -}}
|
{{- $singleView = index . 4 -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $entrySubView := false -}}
|
||||||
|
{{- if gt (len .) 5 -}}
|
||||||
|
{{- $entrySubView = index . 5 -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
<div class="content flex flex-row font-serif" id="{{- $content.Id -}}">
|
<div class="content flex flex-row font-serif" id="{{- $content.Id -}}">
|
||||||
{{- if not $singleView -}}
|
{{- if not $singleView -}}
|
||||||
@@ -41,7 +46,7 @@
|
|||||||
|
|
||||||
<div class="grow columntwo">
|
<div class="grow columntwo">
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
{{- if $singleView -}}
|
{{- if or $singleView $entrySubView -}}
|
||||||
<div class="fieldlabel">Almanach</div>
|
<div class="fieldlabel">Almanach</div>
|
||||||
<div class="fieldvalue">
|
<div class="fieldvalue">
|
||||||
<a href="/almanach/{{- $entry.MusenalmID -}}">
|
<a href="/almanach/{{- $entry.MusenalmID -}}">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
CResult []*dbmodels.Entry /// Sorted
|
CResult []*dbmodels.Entry /// Sorted
|
||||||
Contents map[string][]*dbmodels.Content // KEY: entry ID
|
Contents map[string][]*dbmodels.Content // KEY: entry ID
|
||||||
ContentsAgents map[string][]*dbmodels.RContentsAgents // KEY: Content ID
|
ContentsAgents map[string][]*dbmodels.RContentsAgents // KEY: Content ID
|
||||||
|
Agents map[string]*dbmodels.Agent // KEY: Agent ID
|
||||||
}
|
}
|
||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
@@ -108,17 +109,19 @@
|
|||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{- if len $model.result.CResult -}}
|
||||||
<!--
|
<div class="container-normal mt-0 pt-0" id="almanachcontents">
|
||||||
{{ if .contents }}
|
<div class="mt-8">
|
||||||
<h2>Inhalte</h2>
|
{{- range $_, $e := $model.result.CResult -}}
|
||||||
{{ range $id, $c := .contents }}
|
<div class="font-serif font-bold border-b pb-0.5 mb-2">{{ $e.PreferredTitle }}</div>
|
||||||
<div>
|
{{- $contents := index $model.result.Contents $e.Id -}}
|
||||||
{{ $e := index $model.centries $c.Entry }}
|
<div class="mb-7">
|
||||||
<a href="/almanach/{{ $e.MusenalmID }}">{{ $e.PreferredTitle }}</a>
|
{{- range $i, $c := $contents -}}
|
||||||
{{ $c.PreferredTitle }}
|
{{- $rels := index $model.result.ContentsAgents $c.Id -}}
|
||||||
{{ $c.Numbering }}
|
{{- template "_content" Arr $c $e $rels $model.result.Agents false true -}}
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
</div>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
-->
|
|
||||||
|
|||||||
@@ -74,6 +74,19 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="w-28 ml-4 shrink-0 font-sans text-sm text-right flex flex-row mt-1">
|
||||||
|
{{- if (index $model.bcount $agent.Id) -}}
|
||||||
|
<div class="mr-2">
|
||||||
|
<i class="ri-book-line"></i> {{ index $model.bcount $agent.Id }}
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
{{- if index $model.ccount $agent.Id -}}
|
||||||
|
<div class="">
|
||||||
|
<i class="ri-article-line"></i> {{ index $model.ccount $agent.Id }}
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="w-64 ml-4 shrink-0 {{ if $model.FTS -}}search-result{{- end -}}">
|
<div class="w-64 ml-4 shrink-0 {{ if $model.FTS -}}search-result{{- end -}}">
|
||||||
{{ $agent.References }}
|
{{ $agent.References }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -290,7 +290,7 @@
|
|||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
{{- range $_, $hit := $model.result.Hits -}}
|
{{- range $_, $hit := $model.result.Hits -}}
|
||||||
{{- $series := index $model.result.Series $hit -}}
|
{{- $series := index $model.result.Series $hit -}}
|
||||||
<div class="font-serif font-bold py-1 border border-zinc-300 px-3 mt-6">
|
<div class="font-serif font-bold py-1 border-b border-zinc-300 px-3 mt-6">
|
||||||
<span class="text-base font-sans pr-2 border-zinc-300">Reihe</span>
|
<span class="text-base font-sans pr-2 border-zinc-300">Reihe</span>
|
||||||
<span class="pl-2">{{ $series.Title }}</span>
|
<span class="pl-2">{{ $series.Title }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user