Skip to content

Commit

Permalink
fix(ui): handle no log dir size
Browse files Browse the repository at this point in the history
close #750
  • Loading branch information
tchiotludo committed Oct 24, 2021
1 parent e9785ac commit 21146fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions client/src/utils/converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ export function showTime(milliseconds) {
}

/**
* This function is responsible for showing the bytes in a
* friendly way to the user, making the leases for upper
* This function is responsible for showing the bytes in a
* friendly way to the user, making the leases for upper
* measures such as MB, GB, TB etc.
*
*
* @param {*} bytes value in bytes to show
* @param {*} decimals decimal size place
* @returns
* @returns
*/
export function showBytes(bytes, decimals = 3) {
if (bytes === null || bytes === undefined) return '';
if (bytes === 0) return '0 B';

const kbytes = 1024;
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/org/akhq/models/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,21 @@ public List<LogDir> getLogDir() {
.collect(Collectors.toList());
}

public Optional<Long> getLogDirSize() {
public Long getLogDirSize() {
Integer logDirCount = this.getPartitions().stream()
.map(r -> r.getLogDir().size())
.reduce(0, Integer::sum);

if (logDirCount == 0) {
return Optional.empty();
return null;
}

return Optional.of(this.getPartitions().stream()
.map(Partition::getLogDirSize)
.reduce(0L, Long::sum)
);
return Optional
.of(this.getPartitions().stream()
.map(Partition::getLogDirSize)
.reduce(0L, Long::sum)
)
.orElse(null);
}

public long getSize() {
Expand Down

0 comments on commit 21146fa

Please sign in to comment.