Skip to content

Commit

Permalink
fix(edulint): dedupe requests
Browse files Browse the repository at this point in the history
  • Loading branch information
esoadamo committed Jun 30, 2024
1 parent a2c73fd commit 7e49951
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export class TaskModuleProgrammingComponent implements OnInit, OnDestroy {
if (result.result === 'ok') {
this.lintCode();
}
})
}),
shareReplay(1),
);
(this.codeRun$ = this.codeRunResult$.pipe(mapTo(undefined))).subscribe(() => {
this.codeRun$ = null;
Expand Down
6 changes: 5 additions & 1 deletion src/app/services/tasks/edulint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { APIService, Configuration, WebService } from '../../../api/edulint';
import { environment } from '../../../environments/environment';
import { combineLatest, Observable, of } from 'rxjs';
import { catchError, filter, map, mergeMap } from 'rxjs/operators';
import {catchError, filter, map, mergeMap, shareReplay, take} from 'rxjs/operators';
import { EdulintReport } from '../../models';

@Injectable({
Expand Down Expand Up @@ -31,13 +31,17 @@ export class EdulintService {
code += `\n# edulint: config=${this.config}\n`;

return this.linter.apiCodePost({code}).pipe(
take(1),
shareReplay(1),
catchError((e) => {
environment.logger.error('[EduLint] Code post error', e);
return of({hash: undefined});
}),
filter((response) => response.hash !== undefined),
map(response => `${response.hash}`),
mergeMap((hash) => combineLatest([this.linter.analyzeUploaded(this.version, hash), of(hash)])),
take(1),
shareReplay(1),
map(([problems, hash]) => ({
problems,
editorUrl: `${this.url}/editor/${hash}`
Expand Down

0 comments on commit 7e49951

Please sign in to comment.