From 25b6b43e9fa199248ce1a7652ca785f6a8f7560b Mon Sep 17 00:00:00 2001 From: Patrick <50352812+Mueller-Patrick@users.noreply.github.com> Date: Sat, 29 May 2021 13:57:19 +0200 Subject: [PATCH] BETTERZON-124: Adding service function for crawling status API (#71) --- Frontend/src/app/models/crawlingstatus.ts | 7 +++++++ Frontend/src/app/services/api.service.ts | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Frontend/src/app/models/crawlingstatus.ts diff --git a/Frontend/src/app/models/crawlingstatus.ts b/Frontend/src/app/models/crawlingstatus.ts new file mode 100644 index 0000000..c54d914 --- /dev/null +++ b/Frontend/src/app/models/crawlingstatus.ts @@ -0,0 +1,7 @@ +export interface CrawlingStatus { + process_id: number; + started_timestamp: Date; + combinations_to_crawl: number; + successful_crawls: number; + failed_crawls: number; +} diff --git a/Frontend/src/app/services/api.service.ts b/Frontend/src/app/services/api.service.ts index 4181455..8d06a81 100644 --- a/Frontend/src/app/services/api.service.ts +++ b/Frontend/src/app/services/api.service.ts @@ -10,6 +10,7 @@ import {FavoriteShop} from '../models/favoriteshop'; import {ContactPerson} from '../models/contactperson'; import {Category} from '../models/category'; import {Manufacturer} from '../models/manufacturer'; +import {CrawlingStatus} from '../models/crawlingstatus'; @Injectable({ providedIn: 'root' @@ -575,4 +576,25 @@ export class ApiService { process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`); } } + + + /* ______ ___ _____ __ __ + / ____/________ __ __/ (_)___ ____ _ / ___// /_____ _/ /___ _______ + / / / ___/ __ `/ | /| / / / / __ \/ __ `/ \__ \/ __/ __ `/ __/ / / / ___/ + / /___/ / / /_/ /| |/ |/ / / / / / / /_/ / ___/ / /_/ /_/ / /_/ /_/ (__ ) + \____/_/ \__,_/ |__/|__/_/_/_/ /_/\__, / /____/\__/\__,_/\__/\__,_/____/ + /____/ + */ + + /** + * Gets the current crawling status + * @return Observable An observable containing a single crawling status object + */ + getCurrentCrawlingStatus(): Observable { + try { + return this.http.get((this.apiUrl + '/crawlingstatus')); + } catch (exception) { + process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`); + } + } }