fix:#75 refactoring duplicate function

This commit is contained in:
Elmar Kresse
2025-04-27 13:53:34 +02:00
parent f34a8dfb9f
commit 57c2fcb7ad
8 changed files with 238 additions and 151 deletions

View File

@@ -18,7 +18,6 @@ package v2
import (
"fmt"
"github.com/google/uuid"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
"golang.org/x/net/html"
@@ -169,7 +168,7 @@ func parseEventForOneSemester(url string) ([]model.Event, error) {
return nil, err
}
events = switchNameAndNotesForExam(events)
events = generateUUIDs(events)
events = functions.GenerateUUIDs(events)
return events, nil
}
@@ -194,14 +193,3 @@ func parseHTML(webpage string) (*html.Node, error) {
}
return doc, nil
}
// generateUUIDs generates a UUID for each event based on the event name, course and semester
// the UUID is used to identify the event in the database
func generateUUIDs(events []model.Event) []model.Event {
for i, event := range events {
// generate a hash value from the event name, course and semester
hash := uuid.NewSHA1(uuid.NameSpaceOID, []byte(event.Name+event.Course))
events[i].UUID = hash.String()
}
return events
}