Skip to content

Commit

Permalink
Only show rangeDates if non-default
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Sep 2, 2024
1 parent 208ccfc commit f876481
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/apps/chifra/pkg/types/types_chunkaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func (s *ChunkAddress) Model(chain, format string, verbose bool, extraOpts map[s

if verbose {
if format == "json" {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
if !s.RangeDates.IsDefault() {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
}
} else {
model["firstTs"] = s.RangeDates.FirstTs
model["firstDate"] = s.RangeDates.FirstDate
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/pkg/types/types_chunkbloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (s *ChunkBloom) Model(chain, format string, verbose bool, extraOpts map[str

if verbose {
if format == "json" {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
if !s.RangeDates.IsDefault() {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
}
} else {
model["firstTs"] = s.RangeDates.FirstTs
model["firstDate"] = s.RangeDates.FirstDate
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/pkg/types/types_chunkindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ func (s *ChunkIndex) Model(chain, format string, verbose bool, extraOpts map[str

if verbose {
if format == "json" {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
if !s.RangeDates.IsDefault() {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
}
} else {
model["firstTs"] = s.RangeDates.FirstTs
model["firstDate"] = s.RangeDates.FirstDate
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/pkg/types/types_chunkrecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func (s *ChunkRecord) Model(chain, format string, verbose bool, extraOpts map[st

if verbose {
if format == "json" {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
if !s.RangeDates.IsDefault() {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
}
} else {
model["firstTs"] = s.RangeDates.FirstTs
model["firstDate"] = s.RangeDates.FirstDate
Expand Down
4 changes: 3 additions & 1 deletion src/apps/chifra/pkg/types/types_chunkstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ func (s *ChunkStats) Model(chain, format string, verbose bool, extraOpts map[str

if verbose {
if format == "json" {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
if !s.RangeDates.IsDefault() {
model["rangeDates"] = s.RangeDates.Model(chain, format, verbose, extraOpts).Data
}
} else {
model["firstTs"] = s.RangeDates.FirstTs
model["firstDate"] = s.RangeDates.FirstDate
Expand Down
4 changes: 4 additions & 0 deletions src/apps/chifra/pkg/types/types_rangedates.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ func (p1 *RangeDates) Cmp(p2 RangeDates) int64 {
return p1.FirstTs.Int64() - p2.FirstTs.Int64()
}

func (p1 *RangeDates) IsDefault() bool {
return p1.Cmp(RangeDates{}) == 0
}

// EXISTING_CODE

0 comments on commit f876481

Please sign in to comment.