Skip to content

Commit

Permalink
Solve without using switchMap
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-glombik committed Nov 15, 2024
1 parent fd45565 commit 78679a2
Showing 1 changed file with 45 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SafeHtml } from '@angular/platform-browser';
import { ProgrammingExerciseBuildConfig } from 'app/entities/programming/programming-exercise-build.config';
import { Subject, Subscription, of } from 'rxjs';
import { Subject, Subscription } from 'rxjs';
import { ProgrammingExercise, ProgrammingLanguage } from 'app/entities/programming/programming-exercise.model';
import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service';
import { AlertService, AlertType } from 'app/core/util/alert.service';
Expand Down Expand Up @@ -57,9 +57,8 @@ import { IrisSubSettingsType } from 'app/entities/iris/settings/iris-sub-setting
import { Detail } from 'app/detail-overview-list/detail.model';
import { Competency } from 'app/entities/competency.model';
import { AeolusService } from 'app/exercises/programming/shared/service/aeolus.service';
import { switchMap, tap } from 'rxjs/operators';
import { tap } from 'rxjs/operators';
import { ProgrammingExerciseGitDiffReport } from 'app/entities/hestia/programming-exercise-git-diff-report.model';
import { BuildLogStatisticsDTO } from 'app/entities/programming/build-log-statistics-dto';

@Component({
selector: 'jhi-programming-exercise-detail',
Expand Down Expand Up @@ -194,50 +193,52 @@ export class ProgrammingExerciseDetailComponent implements OnInit, OnDestroy {
this.loadingTemplateParticipationResults = false;
this.loadingSolutionParticipationResults = false;
}),
switchMap(() => this.profileService.getProfileInfo()),
tap(async (profileInfo) => {
if (profileInfo) {
if (this.programmingExercise.projectKey && this.programmingExercise.templateParticipation?.buildPlanId) {
this.programmingExercise.templateParticipation.buildPlanUrl = createBuildPlanUrl(
profileInfo.buildPlanURLTemplate,
this.programmingExercise.projectKey,
this.programmingExercise.templateParticipation.buildPlanId,
);
tap(() =>
this.profileService.getProfileInfo().subscribe((profileInfo) => {
if (profileInfo) {
if (this.programmingExercise.projectKey && this.programmingExercise.templateParticipation?.buildPlanId) {
this.programmingExercise.templateParticipation.buildPlanUrl = createBuildPlanUrl(
profileInfo.buildPlanURLTemplate,
this.programmingExercise.projectKey,
this.programmingExercise.templateParticipation.buildPlanId,
);
}
if (this.programmingExercise.projectKey && this.programmingExercise.solutionParticipation?.buildPlanId) {
this.programmingExercise.solutionParticipation.buildPlanUrl = createBuildPlanUrl(
profileInfo.buildPlanURLTemplate,
this.programmingExercise.projectKey,
this.programmingExercise.solutionParticipation.buildPlanId,
);
}
this.supportsAuxiliaryRepositories =
this.programmingLanguageFeatureService.getProgrammingLanguageFeature(programmingExercise.programmingLanguage).auxiliaryRepositoriesSupported ??
false;
this.localVCEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALVC);
this.localCIEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALCI);
this.irisEnabled = profileInfo.activeProfiles.includes(PROFILE_IRIS);
if (this.irisEnabled) {
this.irisSettingsSubscription = this.irisSettingsService.getCombinedCourseSettings(this.courseId).subscribe((settings) => {
this.irisChatEnabled = settings?.irisChatSettings?.enabled ?? false;
});
}
}
if (this.programmingExercise.projectKey && this.programmingExercise.solutionParticipation?.buildPlanId) {
this.programmingExercise.solutionParticipation.buildPlanUrl = createBuildPlanUrl(
profileInfo.buildPlanURLTemplate,
this.programmingExercise.projectKey,
this.programmingExercise.solutionParticipation.buildPlanId,
);
}
this.supportsAuxiliaryRepositories =
this.programmingLanguageFeatureService.getProgrammingLanguageFeature(programmingExercise.programmingLanguage).auxiliaryRepositoriesSupported ??
false;
this.localVCEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALVC);
this.localCIEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALCI);
this.irisEnabled = profileInfo.activeProfiles.includes(PROFILE_IRIS);
if (this.irisEnabled) {
this.irisSettingsSubscription = this.irisSettingsService.getCombinedCourseSettings(this.courseId).subscribe((settings) => {
this.irisChatEnabled = settings?.irisChatSettings?.enabled ?? false;
});
}
}
}),
switchMap(() => this.programmingExerciseSubmissionPolicyService.getSubmissionPolicyOfProgrammingExercise(exerciseId!)),
tap((submissionPolicy) => {
this.programmingExercise.submissionPolicy = submissionPolicy;
}),
switchMap(() => this.programmingExerciseService.getDiffReport(this.programmingExercise.id!)),
tap((gitDiffReport) => {
this.processGitDiffReport(gitDiffReport);
}),
switchMap(() =>
this.programmingExercise.isAtLeastEditor ? this.programmingExerciseService.getBuildLogStatistics(exerciseId!) : of([] as BuildLogStatisticsDTO),
}),
),
tap(() =>
this.programmingExerciseSubmissionPolicyService.getSubmissionPolicyOfProgrammingExercise(exerciseId!).subscribe((submissionPolicy) => {
this.programmingExercise.submissionPolicy = submissionPolicy;
}),
),
tap(() =>
this.programmingExerciseService.getDiffReport(this.programmingExercise.id!).subscribe((gitDiffReport) => {
this.processGitDiffReport(gitDiffReport);
}),
),
tap((buildLogStatistics) => {
tap(() => {
if (this.programmingExercise.isAtLeastEditor) {
this.programmingExercise.buildLogStatistics = buildLogStatistics;
this.programmingExerciseService.getBuildLogStatistics(exerciseId!).subscribe((buildLogStatistics) => {
this.programmingExercise.buildLogStatistics = buildLogStatistics;
});
}
}),
)
Expand Down

0 comments on commit 78679a2

Please sign in to comment.