From 7a7280bb8596144b1c5de1c13287882ecbb9a8cc Mon Sep 17 00:00:00 2001 From: Lennart Keller <44754405+lennart-keller@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:54:03 +0200 Subject: [PATCH 1/3] Change prefix for tutorial-group channels --- .../TutorialGroupChannelManagementService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java b/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java index fe331781717e..ffb3e1b7e7c7 100644 --- a/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java +++ b/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java @@ -250,7 +250,7 @@ private String determineUniqueTutorialGroupChannelName(TutorialGroup tutorialGro Function determineInitialTutorialGroupChannelName = (TutorialGroup tg) -> { var cleanedTitle = tg.getTitle().replaceAll("\\s", "-").toLowerCase(); // we use $ as prefix to make sure that the channel name is unique (users not allowed to start channel names with $) - return "$" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 19)); + return "tutorgroup-" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 18)); }; var channelName = determineInitialTutorialGroupChannelName.apply(tutorialGroup); @@ -260,14 +260,14 @@ private String determineUniqueTutorialGroupChannelName(TutorialGroup tutorialGro // try to make it unique by adding a random number to the end of the channel name // if already max length remove the last 3 characters to get some space to try to make it unique - if (channelName.length() == 20) { - channelName = channelName.substring(0, 17); + if (channelName.length() == 30) { + channelName = channelName.substring(0, 27); } - while (!channelRepository.findChannelByCourseIdAndName(tutorialGroup.getCourse().getId(), channelName).isEmpty() && channelName.length() <= 20) { + while (!channelRepository.findChannelByCourseIdAndName(tutorialGroup.getCourse().getId(), channelName).isEmpty() && channelName.length() <= 30) { channelName += ThreadLocalRandom.current().nextInt(0, 10); } - if (channelName.length() > 20) { + if (channelName.length() > 30) { // very unlikely to happen throw new IllegalStateException("Could not create a unique channel name for tutorial group with id " + tutorialGroup.getId()); } From 8b4fd44cdaff621b70d9b61eb3d0e2028a3f4d59 Mon Sep 17 00:00:00 2001 From: Lennart Keller <44754405+lennart-keller@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:59:06 +0200 Subject: [PATCH 2/3] Adapt tests --- .../tutorialgroups/AbstractTutorialGroupIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/de/tum/in/www1/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java index 4d8b9266e026..b50da453eb88 100644 --- a/src/test/java/de/tum/in/www1/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java @@ -292,7 +292,7 @@ Channel asserTutorialGroupChannelIsCorrectlyConfigured(TutorialGroup tutorialGro Function expectedTutorialGroupName = (TutorialGroup tg) -> { var cleanedTitle = tg.getTitle().replaceAll("\\s", "-").toLowerCase(); - return "$" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 19)); + return "tutorgroup-" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 18)); }; var tutorialGroupFromDb = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsElseThrow(tutorialGroup.getId()); From 2a6174b5bf032906c13a1965cd4c4455bd652098 Mon Sep 17 00:00:00 2001 From: Lennart Keller <44754405+lennart-keller@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:42:00 +0200 Subject: [PATCH 3/3] Remove obsolete comment --- .../tutorialgroups/TutorialGroupChannelManagementService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java b/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java index ffb3e1b7e7c7..e5a8831a577a 100644 --- a/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java +++ b/src/main/java/de/tum/in/www1/artemis/service/tutorialgroups/TutorialGroupChannelManagementService.java @@ -249,7 +249,6 @@ private Channel createTutorialGroupChannel(TutorialGroup tutorialGroup) { private String determineUniqueTutorialGroupChannelName(TutorialGroup tutorialGroup) { Function determineInitialTutorialGroupChannelName = (TutorialGroup tg) -> { var cleanedTitle = tg.getTitle().replaceAll("\\s", "-").toLowerCase(); - // we use $ as prefix to make sure that the channel name is unique (users not allowed to start channel names with $) return "tutorgroup-" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 18)); };