openaire-library/utils/indexInfo.service.ts

28 lines
956 B
TypeScript
Raw Normal View History

import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {EnvProperties} from './properties/env-properties';
import {Observable, of} from "rxjs";
import {catchError, map} from "rxjs/operators";
@Injectable({
providedIn: "root"
})
export class IndexInfoService {
constructor(private http: HttpClient) {
}
getLastIndexDate(properties: EnvProperties): Observable<any> {
let url = properties.indexInfoAPI;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['claim_load_date'])).pipe(catchError(err => {return of(null)}));
}
getStatsLastDate(properties: EnvProperties): Observable<any> {
let url = properties.indexInfoAPI;
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['stats_update_date'])).pipe(catchError(err => {return of(null)}));
}
}