mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Suche nach Musenalm-ID implementiert
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
package dbmodels
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
type EntriesAgents map[string][]*REntriesAgents
|
||||
|
||||
func EntriesForID(app core.App, query int) ([]*Entry, error) {
|
||||
entries := []*Entry{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
Where(dbx.HashExp{MUSENALMID_FIELD: strconv.Itoa(query)}).
|
||||
All(&entries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
func YearsForEntries(app core.App) ([]int, error) {
|
||||
rec := []core.Record{}
|
||||
err := app.RecordQuery(ENTRIES_TABLE).
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/collate"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
||||
type SeriesEntries map[string][]*REntriesSeries
|
||||
@@ -22,13 +21,25 @@ func SortSeriessesByTitle(series []*Series) {
|
||||
})
|
||||
}
|
||||
|
||||
func MusenalmIDSearchSeries(app core.App, query string) ([]*Series, error) {
|
||||
series := []*Series{}
|
||||
err := app.RecordQuery(SERIES_TABLE).
|
||||
Where(dbx.Like(MUSENALMID_FIELD, query).Match(true, false)).
|
||||
All(&series)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return series, nil
|
||||
}
|
||||
|
||||
func BasicSearchSeries(app core.App, query string) ([]*Series, []*Series, error) {
|
||||
query = strings.TrimSpace(query)
|
||||
query = datatypes.DeleteTags(query)
|
||||
query = datatypes.NormalizeString(query)
|
||||
query = datatypes.RemovePunctuation(query)
|
||||
query = cases.Lower(language.German).String(query)
|
||||
query = norm.NFKD.String(query)
|
||||
// TODO: how to normalize, which unicode normalization to use?
|
||||
|
||||
if query == "" {
|
||||
return []*Series{}, []*Series{}, nil
|
||||
|
||||
Reference in New Issue
Block a user