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

@@ -0,0 +1,17 @@
package functions
import (
"github.com/google/uuid"
"htwkalender/data-manager/model"
)
// 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
}