allocation.js 674 B

12345678910111213141516171819202122232425
  1. import axios from 'axios';
  2. class AllocationService {
  3. BASE_URL = process.env.BASE_URL || '{PLACEHOLDER_BASE_URL}';
  4. async fetchAllocation(win, aggregate, options) {
  5. if (this.BASE_URL.includes('PLACEHOLDER_BASE_URL')) {
  6. this.BASE_URL = `http://localhost:9090/model`
  7. }
  8. const { accumulate, filters, } = options;
  9. const params = {
  10. window: win,
  11. aggregate: aggregate,
  12. step: '1d',
  13. };
  14. if (typeof accumulate === 'boolean') {
  15. params.accumulate = accumulate;
  16. }
  17. const result = await axios.get(`${this.BASE_URL}/allocation/compute`, { params });
  18. return result.data;
  19. }
  20. }
  21. export default new AllocationService();