chore: Rimosso file utenti.go e spostati file .json in _content/

feat/db
Antonio De Lucreziis 2 years ago
parent 805d9a7ba5
commit 192d8ea944

@ -33,7 +33,7 @@ func main() {
NewsArticlesRegistry: articles.NewRegistry("./_content/news"),
GuideArticlesRegistry: articles.NewRegistry("./_content/guide"),
Storia: &storia.JsonFileStoria{
Path: "./storia.json",
Path: "./_content/storia.json",
},
ListaUtenti: listaUtentiService,
}

@ -23,7 +23,7 @@ func New(authService auth.Service, config string) (Service, error) {
}
func loadMacchinisti() (util.Set[string], error) {
f, err := os.Open("macchinisti.json")
f, err := os.Open("_content/macchinisti.json")
if err != nil {
return nil, err
}

@ -133,7 +133,7 @@ func withSpacers(events []*GenericEvent) []*GenericEvent {
func getDateYear(date string) int {
year, err := strconv.Atoi(strings.Split(date, "/")[0])
if err != nil {
panic(err) // Tanto nel caso si nota in fase di sviluppo visto che "storia.json" è statico
panic(err) // Tanto nel caso si nota in fase di sviluppo visto che "_content/storia.json" è statico
}
return year

@ -1,41 +0,0 @@
package website
import (
"encoding/json"
"log"
"os"
)
type UserInfo struct {
Uid string `json:"uid"`
Nome string `json:"nome"`
Cognome string `json:"cognome"`
Tags []string `json:"tags"`
IsMacchinista bool `json:"macchinista,omitempty"`
}
type ListaUtentiService interface {
GetUtenti() ([]UserInfo, error)
}
type JsonFileListaUtenti struct {
Path string
}
func (j *JsonFileListaUtenti) GetUtenti() ([]UserInfo, error) {
var users []UserInfo
usersJsonData, err := os.ReadFile(j.Path)
if err != nil {
return nil, err
}
if err := json.Unmarshal(usersJsonData, &users); err != nil {
return nil, err
}
log.Printf("Loaded list utenti with %d users", len(users))
return users, nil
}
Loading…
Cancel
Save