2021-04-13 21:53:58 +02:00
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { Injectable } from '@angular/core';
|
2021-12-11 11:45:13 +01:00
|
|
|
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
|
|
|
import { DataSource, MarketData } from '@prisma/client';
|
|
|
|
import { format } from 'date-fns';
|
2021-04-13 21:53:58 +02:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class AdminService {
|
|
|
|
public constructor(private http: HttpClient) {}
|
|
|
|
|
|
|
|
public gatherMax() {
|
|
|
|
return this.http.post<void>(`/api/admin/gather/max`, {});
|
|
|
|
}
|
2021-07-24 21:13:48 +02:00
|
|
|
|
|
|
|
public gatherProfileData() {
|
|
|
|
return this.http.post<void>(`/api/admin/gather/profile-data`, {});
|
|
|
|
}
|
2021-11-30 21:06:10 +01:00
|
|
|
|
|
|
|
public gatherSymbol({
|
|
|
|
dataSource,
|
2021-12-11 11:45:13 +01:00
|
|
|
date,
|
2021-11-30 21:06:10 +01:00
|
|
|
symbol
|
|
|
|
}: {
|
|
|
|
dataSource: DataSource;
|
2021-12-11 11:45:13 +01:00
|
|
|
date?: Date;
|
2021-11-30 21:06:10 +01:00
|
|
|
symbol: string;
|
|
|
|
}) {
|
2021-12-11 11:45:13 +01:00
|
|
|
let url = `/api/admin/gather/${dataSource}/${symbol}`;
|
|
|
|
|
|
|
|
if (date) {
|
|
|
|
url = `${url}/${format(date, DATE_FORMAT)}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.http.post<MarketData | void>(url, {});
|
2021-11-30 21:06:10 +01:00
|
|
|
}
|
2021-04-13 21:53:58 +02:00
|
|
|
}
|