From 5128fcbdddaaa87fd6007af6ff23eff0643a01b1 Mon Sep 17 00:00:00 2001 From: masterElmar <18119527+masterElmar@users.noreply.github.com> Date: Fri, 29 Dec 2023 00:05:39 +0100 Subject: [PATCH] feat:#104 changed event selection to uuid --- backend/service/db/dbEvents.go | 10 ++-------- backend/service/db/dbEvents_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/backend/service/db/dbEvents.go b/backend/service/db/dbEvents.go index e301f00..37ed4cf 100644 --- a/backend/service/db/dbEvents.go +++ b/backend/service/db/dbEvents.go @@ -125,20 +125,14 @@ func buildIcalQueryForModules(modules []model.FeedCollection) dbx.Expression { //second check if modules has only one element if len(modules) == 1 { - return dbx.And( - dbx.HashExp{"Name": modules[0].Name}, - dbx.HashExp{"course": modules[0].Course}, - ) + return dbx.HashExp{"uuid": modules[0].UUID} } //third check if modules has more than one element var wheres []dbx.Expression for _, module := range modules { - where := dbx.And( - dbx.HashExp{"Name": module.Name}, - dbx.HashExp{"course": module.Course}, - ) + where := dbx.HashExp{"uuid": module.UUID} wheres = append(wheres, where) } diff --git a/backend/service/db/dbEvents_test.go b/backend/service/db/dbEvents_test.go index 8d46131..b8fa224 100644 --- a/backend/service/db/dbEvents_test.go +++ b/backend/service/db/dbEvents_test.go @@ -23,13 +23,13 @@ func Test_buildIcalQueryForModules(t *testing.T) { }, { name: "one module", - args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}}}, - want: dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}), + args: args{modules: []model.FeedCollection{{Name: "test", Course: "test", UUID: "test"}}}, + want: dbx.HashExp{"uuid": "test"}, }, { name: "two modules", - args: args{modules: []model.FeedCollection{{Name: "test", Course: "test"}, {Name: "test2", Course: "test2"}}}, - want: dbx.Or(dbx.And(dbx.HashExp{"Name": "test"}, dbx.HashExp{"course": "test"}), dbx.And(dbx.HashExp{"Name": "test2"}, dbx.HashExp{"course": "test2"})), + args: args{modules: []model.FeedCollection{{Name: "test", Course: "test", UUID: "test"}, {Name: "test2", Course: "test2", UUID: "test2"}}}, + want: dbx.Or(dbx.HashExp{"uuid": "test"}, dbx.HashExp{"uuid": "test2"}), }, } for _, tt := range tests {