This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit f7a59800 authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Merge branch 'development' into 'master'

Bringing fixes to production

See merge request !277
parents 86c1681e b101146b
1 merge request!277Bringing fixes to production
...@@ -12,7 +12,7 @@ services: ...@@ -12,7 +12,7 @@ services:
- _JAVA_OPTIONS=-Xmx512m -Xms256m - _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE} - SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE}
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true - 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 - JHIPSTER_SLEEP=5 # gives a small time for other services to boot before the application
- SPRING_DATA_JEST_URI=http://sharing_elasticsearch:9200 - SPRING_DATA_JEST_URI=http://sharing_elasticsearch:9200
- SPRING_ELASTICSEARCH_REST_URIS=http://sharing_elasticsearch:9200 - SPRING_ELASTICSEARCH_REST_URIS=http://sharing_elasticsearch:9200
...@@ -91,7 +91,6 @@ services: ...@@ -91,7 +91,6 @@ services:
GITLAB_HOME: $GITLAB_HOME GITLAB_HOME: $GITLAB_HOME
EXTERNAL_URL: $EXTERNAL_URL EXTERNAL_URL: $EXTERNAL_URL
GITLAB_HOSTNAME: $GITLAB_HOSTNAME GITLAB_HOSTNAME: $GITLAB_HOSTNAME
GITLAB_API_ROOT_ACCESS_TOKEN: $GITLAB_API_ROOT_ACCESS_TOKEN
INDEXING_SERVICE_URL: $INDEXING_SERVICE_URL INDEXING_SERVICE_URL: $INDEXING_SERVICE_URL
MAIL_USERNAME: $MAIL_USERNAME MAIL_USERNAME: $MAIL_USERNAME
MAIL_PASSWORD: $MAIL_PASSWORD MAIL_PASSWORD: $MAIL_PASSWORD
......
...@@ -35,10 +35,11 @@ It can be executed as follows: ...@@ -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. - ``. .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 GITLAB_HOME``
- ``export INDEXING_SERVICE_URL`` - ``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`` - ``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. - ``docker-compose -f gitsearch.yml create gitlab`` # this may fail, if the format of the gitsearch-app version needs to be adapted.
.. note:: .. 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`` - ``docker-compose -f gitsearch.yml up -d gitlab plantuml elasticsearch``
The following environment variables are set within the config files. The following environment variables are set within the config files.
......
...@@ -41,6 +41,24 @@ public class StatisticsService { ...@@ -41,6 +41,24 @@ public class StatisticsService {
* @param statisticsDTO the entity to save. * @param statisticsDTO the entity to save.
* @return the persisted entity. * @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) { public StatisticsDTO save(StatisticsDTO statisticsDTO) {
Statistics statistics = new Statistics(); Statistics statistics = new Statistics();
statistics.setId(statisticsDTO.getId()); statistics.setId(statisticsDTO.getId());
...@@ -50,6 +68,11 @@ public class StatisticsService { ...@@ -50,6 +68,11 @@ public class StatisticsService {
statistics.setBadgeRewarded(statisticsDTO.getBadgeRewarded()); statistics.setBadgeRewarded(statisticsDTO.getBadgeRewarded());
statisticsRepository.save(statistics); statisticsRepository.save(statistics);
updateSearchResult(statisticsDTO);
return statisticsDTO;
}
protected void updateSearchResult(StatisticsDTO statisticsDTO) {
try { try {
final SearchResultDTO searchResultDTO = elasticSearchRepository.get(statisticsDTO.getExerciseID()); final SearchResultDTO searchResultDTO = elasticSearchRepository.get(statisticsDTO.getExerciseID());
if (searchResultDTO != null) { if (searchResultDTO != null) {
...@@ -59,7 +82,6 @@ public class StatisticsService { ...@@ -59,7 +82,6 @@ public class StatisticsService {
} catch (IOException e) { } catch (IOException e) {
log.error("Cannot update statistics for {}", statisticsDTO.getExerciseID(), e); log.error("Cannot update statistics for {}", statisticsDTO.getExerciseID(), e);
} }
return statisticsDTO;
} }
/** /**
...@@ -152,7 +174,7 @@ public class StatisticsService { ...@@ -152,7 +174,7 @@ public class StatisticsService {
if (statistics.isPresent()) { if (statistics.isPresent()) {
Statistics statistics1 = statistics.get(); // get last Statistics statistics1 = statistics.get(); // get last
statistics1.setBadgeRewarded(true); statistics1.setBadgeRewarded(true);
statisticsRepository.save(statistics1); save(statistics1);
log.debug("Badge rewarded for exercise: {}", exerciseID); log.debug("Badge rewarded for exercise: {}", exerciseID);
} else { } else {
log.debug("No statistics found for exercise: {}", exerciseID); log.debug("No statistics found for exercise: {}", exerciseID);
......
...@@ -486,8 +486,8 @@ public class ExerciseResource { ...@@ -486,8 +486,8 @@ public class ExerciseResource {
} }
} }
@GetMapping("exercises/{id}/edu-sharing-status") @GetMapping("/exerciseEduSharingStatus")
public ResponseEntity<EduSharingStatusDTO> getEduSharingStatus(@PathVariable("id") String projectId) { public ResponseEntity<EduSharingStatusDTO> getEduSharingStatus(@RequestParam("exerciseId") String projectId) {
try { try {
return this.eduSharingService.getEduSharingStatus(projectId).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build()); return this.eduSharingService.getEduSharingStatus(projectId).map(ResponseEntity::ok).orElse(ResponseEntity.notFound().build());
} catch (EduSharingDisabledException e) { } catch (EduSharingDisabledException e) {
...@@ -495,8 +495,8 @@ public class ExerciseResource { ...@@ -495,8 +495,8 @@ public class ExerciseResource {
} }
} }
@PutMapping("exercises/{id}/edu-sharing-status") @PutMapping("/exerciseEduSharingStatus")
public ResponseEntity<EduSharingStatusDTO> upsertEduSharing(@PathVariable("id") String projectId) throws IOException { public ResponseEntity<EduSharingStatusDTO> upsertEduSharing(@RequestParam("exerciseId") String projectId) throws IOException {
try { try {
return ResponseEntity.ok(this.eduSharingService.tryUpsertToEduSharing(projectId)); return ResponseEntity.ok(this.eduSharingService.tryUpsertToEduSharing(projectId));
} catch (ParseException | IllegalArgumentException e) { } catch (ParseException | IllegalArgumentException e) {
......
...@@ -15,6 +15,7 @@ export class ExerciseService { ...@@ -15,6 +15,7 @@ export class ExerciseService {
public resourceUrl = this.applicationConfigService.getEndpointFor('api/exerciseFile/') public resourceUrl = this.applicationConfigService.getEndpointFor('api/exerciseFile/')
public exerciseUrl: string = this.applicationConfigService.getEndpointFor('api/exercise/') public exerciseUrl: string = this.applicationConfigService.getEndpointFor('api/exercise/')
public exercisesUrl: string = this.applicationConfigService.getEndpointFor('api/exercises') public exercisesUrl: string = this.applicationConfigService.getEndpointFor('api/exercises')
public exerciseEduSharingStatusUrl: string = this.applicationConfigService.getEndpointFor('api/exerciseEduSharingStatus')
public exerciseChildrenUrl: string = this.applicationConfigService.getEndpointFor('api/exerciseChildren/') public exerciseChildrenUrl: string = this.applicationConfigService.getEndpointFor('api/exerciseChildren/')
constructor( constructor(
...@@ -188,22 +189,31 @@ export class ExerciseService { ...@@ -188,22 +189,31 @@ export class ExerciseService {
} }
public getEduSharingStatus(exerciseId: string): Observable<EduSharingStatusDtoModel> { public getEduSharingStatus(exerciseId: string): Observable<EduSharingStatusDtoModel> {
return this.http.get<EduSharingStatusDtoModel>(`${this.exercisesUrl}/${encodeURIforExerciseId(exerciseId)}/edu-sharing-status`).pipe( const parameters = new HttpParams().set('exerciseId', exerciseId)
map((dto: EduSharingStatusDtoModel) => { return this.http
dto.workflows.forEach(workflow => { .get<EduSharingStatusDtoModel>(`${this.exerciseEduSharingStatusUrl}`, {
workflow.time = new Date(workflow.time) params: parameters,
})
return dto
}) })
) .pipe(
map((dto: EduSharingStatusDtoModel) => {
dto.workflows.forEach(workflow => {
workflow.time = new Date(workflow.time)
})
return dto
})
)
} }
public exportExerciseToEduSharing(exerciseId: string): Observable<EduSharingStatusDtoModel> { public exportExerciseToEduSharing(exerciseId: string): Observable<EduSharingStatusDtoModel> {
const parameters = new HttpParams().set('exerciseId', exerciseId)
return this.http return this.http
.put<EduSharingStatusDtoModel>( .put<EduSharingStatusDtoModel>(
`${this.exercisesUrl}/${encodeURIforExerciseId(exerciseId)}/edu-sharing-status`, `${this.exerciseEduSharingStatusUrl}`,
{}, {},
{ observe: 'response' } {
observe: 'response',
params: parameters,
}
) )
.pipe( .pipe(
map((response: HttpResponse<any>) => { map((response: HttpResponse<any>) => {
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
"IMPROVEMENTS_REQUESTED": "Verbesserungen angefordert", "IMPROVEMENTS_REQUESTED": "Verbesserungen angefordert",
"REVIEW_REJECTED": "Überprüfung abgelehnt", "REVIEW_REJECTED": "Überprüfung abgelehnt",
"REVIEW_COMPLETED": "Überprüfung abgeschlossen", "REVIEW_COMPLETED": "Überprüfung abgeschlossen",
"REVIEW_IMPROVED": "Aufgabe verbessert",
"askQuestion": "Chatte mit dem Ersteller", "askQuestion": "Chatte mit dem Ersteller",
"send": "Senden", "send": "Senden",
"typeMessage": "Nachricht für alle eingeben...", "typeMessage": "Nachricht für alle eingeben...",
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
"IMPROVEMENTS_REQUESTED": "Improvements Requested", "IMPROVEMENTS_REQUESTED": "Improvements Requested",
"REVIEW_REJECTED": "Review Rejected", "REVIEW_REJECTED": "Review Rejected",
"REVIEW_COMPLETED": "Review Completed", "REVIEW_COMPLETED": "Review Completed",
"REVIEW_IMPROVED": "Exercise improved",
"askQuestion": "Chat with creator", "askQuestion": "Chat with creator",
"askReviewers": "Chat with reviewers", "askReviewers": "Chat with reviewers",
"send": "Send", "send": "Send",
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment