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

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

Selbes Problem in Likes und Statistics-Service

parent be075016
2 merge requests!132Bringing July Release to production,!128Fixing #315 and #319
......@@ -5,6 +5,8 @@ import { IStatistics } from 'app/shared/model/statistics.model';
import { createRequestOption } from 'app/core/request/request-util';
import { Search } from 'app/core/request/request.model';
import { Observable } from 'rxjs';
import { encodeURIforExerciseId } from 'app/exercise/service/exercise.service'
type EntityResponseType = HttpResponse<IStatistics>;
type EntityArrayResponseType = HttpResponse<IStatistics[]>;
......@@ -43,6 +45,6 @@ export class StatisticsService {
}
getNumberOfWatchListEntriesForExerciseID(exerciseID: string): Observable<number> {
return this.http.get<number>(SERVER_API_URL + 'api/statistics/numberOfWatchlistEntries/' + encodeURIComponent(exerciseID));
return this.http.get<number>(SERVER_API_URL + 'api/statistics/numberOfWatchlistEntries/' + encodeURIforExerciseId(exerciseID));
}
}
......@@ -28,7 +28,7 @@ export class ExerciseService {
const options: HttpParams = new HttpParams();
options.append('filePath', filePath);
return this.http.get<string>(this.resourceUrl + encodeURIComponent(exerciseId), {
return this.http.get<string>(this.resourceUrl + encodeURIforExerciseId(exerciseId), {
headers,
params: new HttpParams().set('filePath', filePath),
responseType: 'text' as 'json',
......@@ -36,18 +36,9 @@ export class ExerciseService {
}
public loadExercise(exerciseId: string): Observable<SearchResultDTO> {
return this.http.get<SearchResultDTO>(this.exerciseUrl + this.encodeURIforExerciseId(exerciseId));
return this.http.get<SearchResultDTO>(this.exerciseUrl + encodeURIforExerciseId(exerciseId));
}
/*
* behind the apache reverse proxy, encoded slashes are not working.
* I have not found a good way to repair this. So we unencode the slashes here.
*/
private encodeURIforExerciseId(exerciseId: string): string {
const encodedURL = encodeURIComponent(exerciseId);
return encodedURL.replace("%2F", "/").replace("%2f", "/")
}
populateExerciseWithData(exercise: Exercise): Exercise {
if (exercise !== undefined) {
exercise.views = 0;
......@@ -106,3 +97,12 @@ export class ExerciseService {
return this.http.post<ArtemisExerciseInfo>(`${this.exerciseUrl}import-exercise/${exerciseToken}/${gitlabGroupId}`, exerciseInfo);
}
}
/*
* behind the apache reverse proxy, encoded slashes are not working.
* I have not found a good way to repair this. So we unencode the slashes here.
*/
export function encodeURIforExerciseId(exerciseId: string): string {
const encodedURL = encodeURIComponent(exerciseId);
return encodedURL.replace("%2F", "/").replace("%2f", "/")
}
......@@ -7,6 +7,7 @@ import { ApplicationConfigService } from 'app/core/config/application-config.ser
import { SearchResultsDTO } from 'app/shared/model/search/search-results-dto.model';
import { SearchInput } from 'app/shared/model/search/search-input.model';
import { Statistics } from 'app/shared/model/statistics.model';
import { encodeURIforExerciseId } from 'app/exercise/service/exercise.service'
@Injectable({ providedIn: 'root' })
export class SearchService {
......@@ -30,7 +31,7 @@ export class SearchService {
}
getStatisticsForExercise(exerciseID: string): Observable<Statistics> {
return this.http.get<Statistics>(this.resourceSearchUrlStatisticsForExercise + encodeURIComponent(exerciseID));
return this.http.get<Statistics>(this.resourceSearchUrlStatisticsForExercise + encodeURIforExerciseId(exerciseID));
}
getStatisticsForUser(): Observable<Statistics> {
......
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