diff --git a/src/main/docker/gitsearch.yml b/src/main/docker/gitsearch.yml index ec97dfa854b6bf5b0c31293fd9d9de2dc80f56a9..f3bb17f89b6450e0a4def318081a4a6d05e633ee 100644 --- a/src/main/docker/gitsearch.yml +++ b/src/main/docker/gitsearch.yml @@ -12,7 +12,7 @@ services: - _JAVA_OPTIONS=-Xmx512m -Xms256m - SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE} - MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true - - SPRING_DATASOURCE_URL=jdbc:mysql://sharing_mysql:3306/gitsearch?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true + - SPRING_DATASOURCE_URL=jdbc:mysql://sharing_mysql:3306/gitsearch?useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true - JHIPSTER_SLEEP=5 # gives a small time for other services to boot before the application - SPRING_DATA_JEST_URI=http://sharing_elasticsearch:9200 - SPRING_ELASTICSEARCH_REST_URIS=http://sharing_elasticsearch:9200 @@ -91,7 +91,6 @@ services: GITLAB_HOME: $GITLAB_HOME EXTERNAL_URL: $EXTERNAL_URL GITLAB_HOSTNAME: $GITLAB_HOSTNAME - GITLAB_API_ROOT_ACCESS_TOKEN: $GITLAB_API_ROOT_ACCESS_TOKEN INDEXING_SERVICE_URL: $INDEXING_SERVICE_URL MAIL_USERNAME: $MAIL_USERNAME MAIL_PASSWORD: $MAIL_PASSWORD diff --git a/src/main/docs/source/filehooks_infrastructure.rst b/src/main/docs/source/filehooks_infrastructure.rst index 093487720f6e9338001f4c86bc7c61a9cb6a6298..02d284d8c7997d9b7e93fb94d7594af43c98cd80 100644 --- a/src/main/docs/source/filehooks_infrastructure.rst +++ b/src/main/docs/source/filehooks_infrastructure.rst @@ -35,10 +35,11 @@ It can be executed as follows: - ``. .env`` the .env file can be found in the KeePass file. It contains the secrets for the containers. A current version of .env can be found in the keepass file. - ``export GITLAB_HOME`` - ``export INDEXING_SERVICE_URL`` + - ``export GITBRANCH=development # or some other gitlab branch`` - ``export COMMIT_ID=$(git rev-parse HEAD); export COMMIT_DATE=$(git show -s --format=%ct`` - ``docker-compose -f gitsearch.yml create gitlab`` # this may fail, if the format of the gitsearch-app version needs to be adapted. .. note:: - the command may complain about missing variables COMMIT_ID, COMMIT_DATE, GITLAB_API_ROOT_ACCESS_TOKEN. This is ok, since the variables are only used in the gitlab container. + the command may complain about missing variables COMMIT_ID, COMMIT_DATE. This is ok, since the variables are only used in the gitlab container. - ``docker-compose -f gitsearch.yml up -d gitlab plantuml elasticsearch`` The following environment variables are set within the config files. diff --git a/src/main/java/at/ac/uibk/gitsearch/service/StatisticsService.java b/src/main/java/at/ac/uibk/gitsearch/service/StatisticsService.java index d84cff1919e92f2e849f8f318cd4a19770b18e13..98c444e9fb3cb73cf85c118cfbd66ebbbe735ea3 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/StatisticsService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/StatisticsService.java @@ -41,6 +41,24 @@ public class StatisticsService { * @param statisticsDTO the entity to save. * @return the persisted entity. */ + /** + * Save a statistics. + * + * @param statisticsDTO the entity to save. + * @return the persisted entity. + */ + public Statistics save(Statistics statistics) { + final Statistics stats = statisticsRepository.save(statistics); + StatisticsDTO statisticsDto = new StatisticsDTO(); + statisticsDto.setId(statistics.getId()); + statisticsDto.setExerciseID(statistics.getExerciseID()); + statisticsDto.setDownloads(statistics.getDownloads()); + statisticsDto.setViews(statistics.getViews()); + statisticsDto.setBadgeRewarded(statistics.getBadgeRewarded()); + updateSearchResult(statisticsDto); + return stats; + } + public StatisticsDTO save(StatisticsDTO statisticsDTO) { Statistics statistics = new Statistics(); statistics.setId(statisticsDTO.getId()); @@ -50,6 +68,11 @@ public class StatisticsService { statistics.setBadgeRewarded(statisticsDTO.getBadgeRewarded()); statisticsRepository.save(statistics); + updateSearchResult(statisticsDTO); + return statisticsDTO; + } + + protected void updateSearchResult(StatisticsDTO statisticsDTO) { try { final SearchResultDTO searchResultDTO = elasticSearchRepository.get(statisticsDTO.getExerciseID()); if (searchResultDTO != null) { @@ -59,7 +82,6 @@ public class StatisticsService { } catch (IOException e) { log.error("Cannot update statistics for {}", statisticsDTO.getExerciseID(), e); } - return statisticsDTO; } /** @@ -152,7 +174,7 @@ public class StatisticsService { if (statistics.isPresent()) { Statistics statistics1 = statistics.get(); // get last statistics1.setBadgeRewarded(true); - statisticsRepository.save(statistics1); + save(statistics1); log.debug("Badge rewarded for exercise: {}", exerciseID); } else { log.debug("No statistics found for exercise: {}", exerciseID); diff --git a/src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java b/src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java index 43a7b638ff4985677497588d02af85e7da84cdbe..deb0eb38dfcc7686a51710631a2e0f0b6a4e7626 100644 --- a/src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java +++ b/src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java @@ -486,8 +486,8 @@ public class ExerciseResource { } } - @GetMapping("exercises/{id}/edu-sharing-status") - public ResponseEntity<EduSharingStatusDTO> getEduSharingStatus(@PathVariable("id") String projectId) { + @GetMapping("/exerciseEduSharingStatus") + public ResponseEntity<EduSharingStatusDTO> getEduSharingStatus(@RequestParam("exerciseId") String projectId) { try { return this.eduSharingService.getEduSharingStatus(projectId).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); } catch (EduSharingDisabledException e) { @@ -495,8 +495,8 @@ public class ExerciseResource { } } - @PutMapping("exercises/{id}/edu-sharing-status") - public ResponseEntity<EduSharingStatusDTO> upsertEduSharing(@PathVariable("id") String projectId) throws IOException { + @PutMapping("/exerciseEduSharingStatus") + public ResponseEntity<EduSharingStatusDTO> upsertEduSharing(@RequestParam("exerciseId") String projectId) throws IOException { try { return ResponseEntity.ok(this.eduSharingService.tryUpsertToEduSharing(projectId)); } catch (ParseException | IllegalArgumentException e) { diff --git a/src/main/webapp/app/exercise/service/exercise.service.ts b/src/main/webapp/app/exercise/service/exercise.service.ts index 722714415e2faaf568b4e26883400a05ba56eb40..759a7438e79a3ecefe94b224a0ea0085d315ac6d 100644 --- a/src/main/webapp/app/exercise/service/exercise.service.ts +++ b/src/main/webapp/app/exercise/service/exercise.service.ts @@ -15,6 +15,7 @@ export class ExerciseService { public resourceUrl = this.applicationConfigService.getEndpointFor('api/exerciseFile/') public exerciseUrl: string = this.applicationConfigService.getEndpointFor('api/exercise/') public exercisesUrl: string = this.applicationConfigService.getEndpointFor('api/exercises') + public exerciseEduSharingStatusUrl: string = this.applicationConfigService.getEndpointFor('api/exerciseEduSharingStatus') public exerciseChildrenUrl: string = this.applicationConfigService.getEndpointFor('api/exerciseChildren/') constructor( @@ -188,22 +189,31 @@ export class ExerciseService { } public getEduSharingStatus(exerciseId: string): Observable<EduSharingStatusDtoModel> { - return this.http.get<EduSharingStatusDtoModel>(`${this.exercisesUrl}/${encodeURIforExerciseId(exerciseId)}/edu-sharing-status`).pipe( - map((dto: EduSharingStatusDtoModel) => { - dto.workflows.forEach(workflow => { - workflow.time = new Date(workflow.time) - }) - return dto + const parameters = new HttpParams().set('exerciseId', exerciseId) + return this.http + .get<EduSharingStatusDtoModel>(`${this.exerciseEduSharingStatusUrl}`, { + params: parameters, }) - ) + .pipe( + map((dto: EduSharingStatusDtoModel) => { + dto.workflows.forEach(workflow => { + workflow.time = new Date(workflow.time) + }) + return dto + }) + ) } public exportExerciseToEduSharing(exerciseId: string): Observable<EduSharingStatusDtoModel> { + const parameters = new HttpParams().set('exerciseId', exerciseId) return this.http .put<EduSharingStatusDtoModel>( - `${this.exercisesUrl}/${encodeURIforExerciseId(exerciseId)}/edu-sharing-status`, + `${this.exerciseEduSharingStatusUrl}`, {}, - { observe: 'response' } + { + observe: 'response', + params: parameters, + } ) .pipe( map((response: HttpResponse<any>) => { diff --git a/src/main/webapp/i18n/de/reviews.json b/src/main/webapp/i18n/de/reviews.json index 9710c5413116770a7a8e2352d213927a3956e6b9..bc00cc812f64d895b3d65b0b4c41cab43c22b156 100644 --- a/src/main/webapp/i18n/de/reviews.json +++ b/src/main/webapp/i18n/de/reviews.json @@ -56,6 +56,7 @@ "IMPROVEMENTS_REQUESTED": "Verbesserungen angefordert", "REVIEW_REJECTED": "Überprüfung abgelehnt", "REVIEW_COMPLETED": "Überprüfung abgeschlossen", + "REVIEW_IMPROVED": "Aufgabe verbessert", "askQuestion": "Chatte mit dem Ersteller", "send": "Senden", "typeMessage": "Nachricht für alle eingeben...", diff --git a/src/main/webapp/i18n/en/reviews.json b/src/main/webapp/i18n/en/reviews.json index 2ab92aa42b6967469b7ecc685db2bed8772c4f2b..c5a7cb6aefcb9829cac2cdb393416b99758e43fb 100644 --- a/src/main/webapp/i18n/en/reviews.json +++ b/src/main/webapp/i18n/en/reviews.json @@ -57,6 +57,7 @@ "IMPROVEMENTS_REQUESTED": "Improvements Requested", "REVIEW_REJECTED": "Review Rejected", "REVIEW_COMPLETED": "Review Completed", + "REVIEW_IMPROVED": "Exercise improved", "askQuestion": "Chat with creator", "askReviewers": "Chat with reviewers", "send": "Send",