Skip to content

🛠️ Refactor suggestion: Fragile string-based parsing of byte sizes #1187

Closed
@de-sh

Description

@de-sh

Splitting on " Bytes" and re-parsing is susceptible to format changes. A more robust approach is to store sizes as numeric fields within the QueriedStats, IngestionStats, and StorageStats, then only format them when returning or displaying. This prevents runtime errors if the format changes and simplifies logic.

 pub fn merge(stats: Vec<Self>) -> Self {
     // Instead of brandishing " Bytes" mid-calculation, define numeric fields in these structs:
     //   - e.g., `pub size_in_bytes: u64`
     // Summation is then just numeric addition.
     // Then, in display or response, format with "Bytes".
 }

Also applies to: 95-128, 130-136

Originally posted by @coderabbitai[bot] in #1150 (comment)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions