report.js 977 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import internalDeadHost from "./dead-host.js";
  2. import internalProxyHost from "./proxy-host.js";
  3. import internalRedirectionHost from "./redirection-host.js";
  4. import internalStream from "./stream.js";
  5. const internalReport = {
  6. /**
  7. * @param {Access} access
  8. * @return {Promise}
  9. */
  10. getHostsReport: (access) => {
  11. return access
  12. .can("reports:hosts", 1)
  13. .then((access_data) => {
  14. const userId = access.token.getUserId(1);
  15. const promises = [
  16. internalProxyHost.getCount(userId, access_data.visibility),
  17. internalRedirectionHost.getCount(userId, access_data.visibility),
  18. internalStream.getCount(userId, access_data.visibility),
  19. internalDeadHost.getCount(userId, access_data.visibility),
  20. ];
  21. return Promise.all(promises);
  22. })
  23. .then((counts) => {
  24. return {
  25. proxy: counts.shift(),
  26. redirection: counts.shift(),
  27. stream: counts.shift(),
  28. dead: counts.shift(),
  29. };
  30. });
  31. },
  32. };
  33. export default internalReport;