From bce1769e43b69acf44913af10013e39fcfc58461 Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Mon, 5 Jun 2023 22:43:10 +0300 Subject: [PATCH 1/4] 2508: fix and switch on job which clear unused pictures --- .../com/epam/brn/job/UnverifiedPicturesClearJob.kt | 12 ++++++++---- src/main/resources/application.properties | 5 +++-- .../epam/brn/job/UnverifiedPicturesClearJobTest.kt | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/epam/brn/job/UnverifiedPicturesClearJob.kt b/src/main/kotlin/com/epam/brn/job/UnverifiedPicturesClearJob.kt index bb0383f47..a5f185f52 100644 --- a/src/main/kotlin/com/epam/brn/job/UnverifiedPicturesClearJob.kt +++ b/src/main/kotlin/com/epam/brn/job/UnverifiedPicturesClearJob.kt @@ -3,6 +3,7 @@ package com.epam.brn.job import com.epam.brn.service.cloud.CloudService import org.apache.logging.log4j.kotlin.logger import org.springframework.beans.factory.annotation.Value +import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component @@ -15,11 +16,14 @@ class UnverifiedPicturesClearJob(private val cloudService: CloudService) { private val log = logger() - // todo: fix it as now it removes folder unverified - // @Scheduled(cron = "\${brn.resources.unverified-pictures.clean-job.cron}") + @Scheduled(cron = "\${brn.resources.unverified-pictures.clean-job.cron}") fun clearUnusedPictures() { - val defaultFolderPictures = cloudService.getFileNames(defaultPicturesPath) - val unverifiedFolderPictures = cloudService.getFileNames(unverifiedPicturesPath) + val unverifiedFolderPictures: List = cloudService + .getFileNames(unverifiedPicturesPath) + .filter { it != "/" } + val defaultFolderPictures: List = cloudService + .getFileNames(defaultPicturesPath) + .filter { it != "/" } val fileNamesToDelete = defaultFolderPictures .intersect(unverifiedFolderPictures) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 08ae7a846..9e00a35b3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -85,8 +85,9 @@ brn.resources.pictures.ext=png # The max size of upload unverified picture to cloud. Possible values: 1B, 1KB, 1MB, 1GB, 1TB. If not set data unit will use: BYTES brn.resources.unverified-pictures.max-size=512KB brn.resources.contributor-pictures.max-size=10MB -# Every night -brn.resources.unverified-pictures.clean-job.cron = 0 0 0 * * * +# Every week oon monday +#brn.resources.unverified-pictures.clean-job.cron = 0 0 1 * * MON +brn.resources.unverified-pictures.clean-job.cron = 0 0/5 * * * ? # Monthly brn.resources.pictures.update-job.cron = 0 0 0 1 * * diff --git a/src/test/kotlin/com/epam/brn/job/UnverifiedPicturesClearJobTest.kt b/src/test/kotlin/com/epam/brn/job/UnverifiedPicturesClearJobTest.kt index 204703996..b7045df63 100644 --- a/src/test/kotlin/com/epam/brn/job/UnverifiedPicturesClearJobTest.kt +++ b/src/test/kotlin/com/epam/brn/job/UnverifiedPicturesClearJobTest.kt @@ -28,8 +28,8 @@ internal class UnverifiedPicturesClearJobTest { ReflectionTestUtils.setField(unverifiedPicturesClearJob, "unverifiedPicturesPath", "unverifiedPicturesPath") val capturedFileNames = slot>() - every { cloudService.getFileNames("defaultPicturesPath") } returns listOf("/file1.png", "/file2.png") - every { cloudService.getFileNames("unverifiedPicturesPath") } returns listOf("/file2.png", "/file3.png") + every { cloudService.getFileNames("defaultPicturesPath") } returns listOf("/file1.png", "/file2.png", "/") + every { cloudService.getFileNames("unverifiedPicturesPath") } returns listOf("/file2.png", "/file3.png", "/") every { cloudService.deleteFiles(capture(capturedFileNames)) } just Runs // WHEN From 1c3f86775d465362e8efc444eb9dde55e8b1ce6e Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Wed, 7 Jun 2023 14:02:34 +0300 Subject: [PATCH 2/4] 2508: fix and switch on job which clear unused pictures --- src/main/resources/application.properties | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9e00a35b3..63b49ace1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -75,7 +75,7 @@ brn.picture.file.default.path=pictures/%s.jpg # The default path in cloud with picture brn.resources.default-pictures.path=pictures/ # The path for upload unverified picture to cloud -brn.resources.unverified-pictures.path=pictures/unverified +brn.resources.unverified-pictures.path=pictures-unverified # The path for upload contributor pictures brn.resources.contributor-pictures.path=pictures/contributors # The extensions allowed for upload unverified picture to cloud @@ -85,11 +85,14 @@ brn.resources.pictures.ext=png # The max size of upload unverified picture to cloud. Possible values: 1B, 1KB, 1MB, 1GB, 1TB. If not set data unit will use: BYTES brn.resources.unverified-pictures.max-size=512KB brn.resources.contributor-pictures.max-size=10MB -# Every week oon monday -#brn.resources.unverified-pictures.clean-job.cron = 0 0 1 * * MON -brn.resources.unverified-pictures.clean-job.cron = 0 0/5 * * * ? +# Every week on monday +brn.resources.unverified-pictures.clean-job.cron = 0 0 1 * * MON +#for testing +#brn.resources.unverified-pictures.clean-job.cron = 0 0/35 * * * ? # Monthly brn.resources.pictures.update-job.cron = 0 0 0 1 * * +#for testing +#brn.resources.pictures.update-job.cron = 0 0/1 * * * ? brn.dataFormatNumLines=5 brn.statistic.progress.day.status.bad.minimal=0 From 97db0f039c460f0781a6bab8dbfa8e139cad8f19 Mon Sep 17 00:00:00 2001 From: Elena Moshnikova Date: Fri, 4 Oct 2024 18:11:19 +0300 Subject: [PATCH 3/4] 2590 fix version update --- src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt | 2 +- src/main/resources/initFiles/series_sentences_ru.csv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt b/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt index d2f386855..6d4d4cc91 100644 --- a/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt +++ b/src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt @@ -21,7 +21,7 @@ class SwaggerConfig { .contact( Contact() .name("Elena.Moshnikova") - .url("https://www.epam.com/") + .url("https://t.me/ElenaLovesSpb") .email("brainupproject@yandex.ru") ) diff --git a/src/main/resources/initFiles/series_sentences_ru.csv b/src/main/resources/initFiles/series_sentences_ru.csv index 23d3dd00c..a4e270f56 100644 --- a/src/main/resources/initFiles/series_sentences_ru.csv +++ b/src/main/resources/initFiles/series_sentences_ru.csv @@ -50,7 +50,7 @@ level,code,exerciseName,orderNumber,words 12,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(мудрая великая);(волшебница фея);(прощает поёт);();()) 13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(великодушный трусливый);(рыцарь кузнец);(спрашивает отвечает);();()) 13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(смелая храбрая);(муха лягушка);(сражается борется);();()) -14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три семь);();(поросёнка волчонка);(строят дуют);();()) +14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(поросёнка волчонка);(строят дуют);();()) 15,sentence_with_3_words,Пойми предложение из 3 слов,2,((двенадцать семнадцать);();(лебедей червяков);(летят ползут);();()) 16,sentence_with_3_words,Пойми предложение из 3 слов,2,((три два);();(дядюшки зайца);(бегут стоят);();()) 17,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(зайчонка лисы);(пищат шумят);();()) From bf962551f57624185b03450fd5d98260fd0472f7 Mon Sep 17 00:00:00 2001 From: Elena_Moshnikova Date: Sun, 24 Nov 2024 21:23:47 +0300 Subject: [PATCH 4/4] fix --- .../kotlin/com/epam/brn/service/impl/UserAnalyticsServiceImpl.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/com/epam/brn/service/impl/UserAnalyticsServiceImpl.kt b/src/main/kotlin/com/epam/brn/service/impl/UserAnalyticsServiceImpl.kt index 38656931a..9f50a4562 100644 --- a/src/main/kotlin/com/epam/brn/service/impl/UserAnalyticsServiceImpl.kt +++ b/src/main/kotlin/com/epam/brn/service/impl/UserAnalyticsServiceImpl.kt @@ -64,7 +64,6 @@ class UserAnalyticsServiceImpl( this.doneExercises = userStatistic.doneExercises } } - return users }