translateLogdirs.ts 640 B

1234567891011121314151617181920212223
  1. import { BrokersLogdirs } from 'generated-sources';
  2. import { BrokerLogdirState } from 'components/Brokers/Broker/Broker';
  3. export const translateLogdir = (data: BrokersLogdirs): BrokerLogdirState => {
  4. const partitionsCount =
  5. data.topics?.reduce(
  6. (prevValue, value) => prevValue + (value.partitions?.length || 0),
  7. 0
  8. ) || 0;
  9. return {
  10. name: data.name || '-',
  11. error: data.error || '-',
  12. topics: data.topics?.length || 0,
  13. partitions: partitionsCount,
  14. };
  15. };
  16. export const translateLogdirs = (
  17. data: BrokersLogdirs[] | undefined
  18. ): BrokerLogdirState[] => {
  19. return data?.map(translateLogdir) || [];
  20. };