mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 09:05:30 +00:00
some bug fixes
This commit is contained in:
@@ -35,34 +35,23 @@ func (i Issue) Keys() []string {
|
||||
}
|
||||
|
||||
res := make([]string, 2)
|
||||
date := i.Datum.When
|
||||
date := i.Datum.When.String()
|
||||
if date != "" {
|
||||
res = append(res, date)
|
||||
}
|
||||
|
||||
if ref, err := i.Reference(); err == nil {
|
||||
res = append(res, ref)
|
||||
}
|
||||
|
||||
res = append(res, i.Reference())
|
||||
i.keys = res
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// TODO: We could even cache this
|
||||
func (i Issue) Year() (int, error) {
|
||||
if date := i.Datum.Date(); date != nil {
|
||||
return date.Year(), nil
|
||||
}
|
||||
return 0, InvalidDateError
|
||||
func (i Issue) Year() int {
|
||||
return i.Datum.When.Year
|
||||
}
|
||||
|
||||
func (i Issue) Reference() (string, error) {
|
||||
if date := i.Datum.Date(); date != nil {
|
||||
return strconv.Itoa(date.Year()) + "-" + strconv.Itoa(i.Number.No), nil
|
||||
}
|
||||
|
||||
return "", InvalidDateError
|
||||
func (i Issue) Reference() string {
|
||||
return strconv.Itoa(i.Number.No) + "-" + i.Datum.When.String()
|
||||
}
|
||||
|
||||
func (i Issue) String() string {
|
||||
|
||||
@@ -41,21 +41,17 @@ func (p Piece) Keys() []string {
|
||||
uid := uuid.New()
|
||||
|
||||
for _, i := range p.IssueRefs {
|
||||
if d := i.Date(); d != nil {
|
||||
ret = append(ret, strconv.Itoa(d.Year())+"-"+strconv.Itoa(i.Nr)+"-"+uid.String())
|
||||
}
|
||||
ret = append(ret, strconv.Itoa(i.When.Year)+"-"+strconv.Itoa(i.Nr)+"-"+uid.String())
|
||||
}
|
||||
|
||||
p.keys = ret
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (p Piece) ReferencesIssue(y, no int) (*IssueRef, bool) {
|
||||
for _, i := range p.IssueRefs {
|
||||
if i.Nr == no {
|
||||
d := i.Date()
|
||||
if d != nil && d.Year() == y {
|
||||
if i.When.Year == y {
|
||||
return &i, true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user