Skip to content

Commit

Permalink
Make public if aggregate-table-json is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
edlu77 committed Apr 22, 2024
1 parent 852a5d8 commit 0463d01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class DatasetLoaderService {
* @returns parsed results
*/
private parseRawData(data: RawData): ParseResults {
if (!data) {
return { datasets: [], variables: [] };
}

const datasets: Dataset[] = [];
const variables: DatasetVariable[] = [];

Expand Down
16 changes: 1 addition & 15 deletions apps/a2agc/src/app/core/state/data/data.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DataState extends NgxsImmutableDataRepository<DataStateModel> {
isPrivate(): Observable<boolean> {
const response = this.http.get<string>(DATA_CONFIG.datasetsPath);
return response.pipe(
map((result) => this.isValidJson(result)),
map((result) => !!result),
catchError(this.handleError)
);
}
Expand All @@ -70,18 +70,4 @@ export class DataState extends NgxsImmutableDataRepository<DataStateModel> {
private handleError(): Observable<boolean> {
return of(false);
}

/**
* Checks if string is valid json
* @param input string
* @returns true if valid json
*/
private isValidJson(input: string): boolean {
try {
JSON.parse(input);
return true;
} catch {
return false;
}
}
}

0 comments on commit 0463d01

Please sign in to comment.