Skip to content

Commit

Permalink
fix LID web UI (#1745)
Browse files Browse the repository at this point in the history
* handle case when total=0

* handle count=0

* add loggers for debug level -vv

* handle empty lastscan time

---------

Co-authored-by: LexLuthr <[email protected]>
  • Loading branch information
nonsense and LexLuthr committed Oct 13, 2023
1 parent 4cf3c0a commit d590a27
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker/devnet/boost/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sed 's|#ServiceApiInfo = ""|ServiceApiInfo = "ws://localhost:8042"|g' $BOOST_PAT
sed 's|#ExpectedSealDuration = "24h0m0s"|ExpectedSealDuration = "0h0m10s"|g' $BOOST_PATH/config.toml > $BOOST_PATH/config.toml.tmp; cp $BOOST_PATH/config.toml.tmp $BOOST_PATH/config.toml; rm $BOOST_PATH/config.toml.tmp

## run boostd-data
boostd-data run leveldb --repo $BOOST_PATH --addr=0.0.0.0:8042 &
boostd-data --vv run leveldb --repo $BOOST_PATH --addr=0.0.0.0:8042 > $BOOST_PATH/boostd-data.log &

# TODO(anteva): fixme: hack as boostd fails to start without this dir
mkdir -p /var/lib/boost/deal-staging
Expand Down
2 changes: 2 additions & 0 deletions extern/boostd-data/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func before(cctx *cli.Context) error {

if cliutil.IsVeryVerbose {
_ = logging.SetLogLevel("boostd-data", "DEBUG")
_ = logging.SetLogLevel("boostd-data-ldb", "DEBUG")
_ = logging.SetLogLevel("boostd-data-yb", "DEBUG")
}

return nil
Expand Down
7 changes: 6 additions & 1 deletion extern/boostd-data/ldb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,13 @@ func (db *DB) ScanProgress(ctx context.Context, maddr address.Address) (*types.S
}
checkedLk.Unlock()

progress := float64(1.0)
if count != 0 {
progress = float64(checkedCount) / float64(count)
}

return &types.ScanProgress{
Progress: float64(checkedCount) / float64(count),
Progress: progress,
LastScan: lastScan,
}, nil
}
Expand Down
7 changes: 5 additions & 2 deletions extern/boostd-data/yugabyte/piecedoctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,11 @@ func (s *Store) ScanProgress(ctx context.Context, maddr address.Address) (*types
return nil, fmt.Errorf("getting time piece tracker was last scanned: %w", err)
}

// Calculate approximate progress
progress := float64(scanned) / float64(total)
progress := float64(1)
if total != 0 {
// Calculate approximate progress
progress = float64(scanned) / float64(total)
}

// Given that the denominator may be a little inflated, round up to 100% if we're close
if progress > 0.95 {
Expand Down
3 changes: 3 additions & 0 deletions react/src/LID.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ function LIDContent() {
var lastScanMsg = ''
var lastScan = d.ScanProgress.LastScan
const now = new Date()
if (!lastScan) {
lastScan = now
}
if (lastScan > now) {
lastScanMsg = 'just now'
} else if (now.getTime() - lastScan.getTime() < 60 * 1000) {
Expand Down

0 comments on commit d590a27

Please sign in to comment.