mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-28 16:45:32 +00:00
Parselog & Issue start
This commit is contained in:
@@ -2,6 +2,7 @@ package viewmodels
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/providers/xmlprovider"
|
||||
@@ -24,30 +25,19 @@ func NewSingleIssueView(y string, No string, lib *xmlprovider.Library) (*SingleI
|
||||
}
|
||||
|
||||
sivm := SingleIssueViewModel{IssueViewModel: *ivm}
|
||||
logging.Info(strconv.Itoa(len(lib.Pieces.All())) + "pieces in library")
|
||||
logging.Info(strconv.Itoa(len(lib.Pieces.Everything())) + "pieces in library")
|
||||
|
||||
lookfor := y + "-" + No
|
||||
lib.Pieces.Items.Range(func(key, value interface{}) bool {
|
||||
a := value.(xmlprovider.Piece)
|
||||
for _, r := range a.IssueRefs {
|
||||
if r.Datum == y && r.Nr == No {
|
||||
p, err := NewPieceView(a)
|
||||
if err != nil {
|
||||
logging.ObjErr(&a, err)
|
||||
continue
|
||||
}
|
||||
sivm.Pieces = append(sivm.Pieces, p)
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range a.AdditionalRef {
|
||||
if r.Datum == y && r.Nr == No {
|
||||
p, err := NewPieceView(a)
|
||||
if err != nil {
|
||||
logging.ObjErr(&a, err)
|
||||
continue
|
||||
}
|
||||
sivm.Additionals = append(sivm.Additionals, p)
|
||||
k := key.(string)
|
||||
if strings.HasPrefix(k, lookfor) {
|
||||
a := value.(xmlprovider.Piece)
|
||||
p, err := NewPieceView(a)
|
||||
if err != nil {
|
||||
logging.ObjErr(&a, err)
|
||||
return true
|
||||
}
|
||||
sivm.Pieces = append(sivm.Pieces, p)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -23,18 +23,19 @@ func YearView(year string, lib *xmlprovider.Library) (*YearViewModel, error) {
|
||||
last := ""
|
||||
|
||||
lib.Issues.Items.Range(func(key, value interface{}) bool {
|
||||
issue := value.(xmlprovider.Issue)
|
||||
if len(issue.Datum.When) < 4 {
|
||||
k := key.(string)
|
||||
if len(k) < 4 {
|
||||
return true
|
||||
}
|
||||
|
||||
date := issue.Datum.When[0:4]
|
||||
date := k[0:4]
|
||||
if date != last {
|
||||
res.PushAvailable(date)
|
||||
last = date
|
||||
}
|
||||
|
||||
if date == year {
|
||||
issue := value.(xmlprovider.Issue)
|
||||
res.PushIssue(issue)
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user