allocation.js 706 B

12345678910111213141516171819202122232425262728
  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. includeIdle: true,
  13. step: "1d",
  14. };
  15. if (typeof accumulate === "boolean") {
  16. params.accumulate = accumulate;
  17. }
  18. const result = await axios.get(`${this.BASE_URL}/allocation/compute`, {
  19. params,
  20. });
  21. return result.data;
  22. }
  23. }
  24. export default new AllocationService();