Skip to content

Commit

Permalink
feat: split flagged pieces page into flagged / flagged because unseal…
Browse files Browse the repository at this point in the history
…ed (#1509)
  • Loading branch information
dirkmc authored and LexLuthr committed Jul 20, 2023
1 parent a8d1cf4 commit a3c76b0
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 29 deletions.
14 changes: 14 additions & 0 deletions gql/resolver_piece.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ func (r *resolver) PiecesFlagged(ctx context.Context, args piecesFlaggedArgs) (*
}, nil
}

type piecesFlaggedCountArgs struct {
HasUnsealedCopy graphql.NullBool
}

func (r *resolver) PiecesFlaggedCount(ctx context.Context, args piecesFlaggedCountArgs) (int32, error) {
var filter *types.FlaggedPiecesListFilter
if args.HasUnsealedCopy.Set && args.HasUnsealedCopy.Value != nil {
filter = &types.FlaggedPiecesListFilter{HasUnsealedCopy: *args.HasUnsealedCopy.Value}
}

count, err := r.piecedirectory.FlaggedPiecesCount(ctx, filter)
return int32(count), err
}

func (r *resolver) PiecesWithPayloadCid(ctx context.Context, args struct{ PayloadCid string }) ([]string, error) {
payloadCid, err := cid.Parse(args.PayloadCid)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions gql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ type RootQuery {
"""Get a list of pieces that have been flagged as having problems"""
piecesFlagged(hasUnsealedCopy: Boolean, cursor: BigInt, offset: Int, limit: Int): FlaggedPiecesList!

"""Get the number of pieces that have been flagged as having problems"""
piecesFlaggedCount(hasUnsealedCopy: Boolean): Int!

"""Get information about a piece from the piece store, DAG store and database"""
pieceStatus(pieceCid: String!): PieceStatus!

Expand Down
6 changes: 4 additions & 2 deletions react/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {LegacyDealDetail} from "./LegacyDealDetail"
import {SettingsPage} from "./Settings";
import {Banner} from "./Banner";
import {ProposalLogsPage} from "./ProposalLogs";
import {PieceDoctorPage, InspectPiecePage, LIDPage} from "./LID";
import {PieceDoctorPage, InspectPiecePage, LIDPage, NoUnsealedSectorPieces, NoUnsealedSectorPage} from "./LID";
import {RetrievalLogsPage} from "./RetrievalLogs";
import {RetrievalLogDetail} from "./RetrievalLogDetail";
import {MonitoringAlert} from "./MonitoringAlert";
Expand Down Expand Up @@ -63,9 +63,11 @@ function App(props) {
<Route path="/deals/:dealID" element={<DealDetail />} />
<Route path="/legacy-deals/:dealID" element={<LegacyDealDetail />} />
<Route path="/piece-doctor" element={<PieceDoctorPage />} />
<Route path="/piece-doctor/piece/:pieceCID" element={<InspectPiecePage />} />
<Route path="/piece-doctor/from/:cursor/page/:pageNum" element={<PieceDoctorPage />} />
<Route path="/piece-doctor/:query" element={<PieceDoctorPage />} />
<Route path="/piece-doctor/piece/:pieceCID" element={<InspectPiecePage />} />
<Route path="/no-unsealed" element={<NoUnsealedSectorPage />} />
<Route path="/no-unsealed/from/:cursor/page/:pageNum" element={<NoUnsealedSectorPage />} />
<Route path="/" element={<StorageDealsPage />} />
</Routes>
</div>
Expand Down
4 changes: 4 additions & 0 deletions react/src/LID.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.nav-link {
margin-left: 1em;
}

.block-stats th {
text-align: left;
}
Expand Down
85 changes: 60 additions & 25 deletions react/src/LID.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {Info, InfoListItem} from "./Info";
import {CumulativeBarChart, CumulativeBarLabels} from "./CumulativeBarChart";
import {addCommas, humanFileSize} from "./util";

const lidBasePath = '/piece-doctor'

export function LIDMenuItem(props) {
return (
<Link key="lid" className="menu-item" to={"/lid"}>
Expand Down Expand Up @@ -257,6 +259,14 @@ function FlaggedPieces({setSearchQuery}) {
Flagged pieces ({totalCount})
</h3>

<table>
<tbody>
<tr>
<th>Piece CID</th>
<th>Index</th>
<th>Deals</th>
</tr>

{ totalCount ? (
<>
<table>
Expand Down Expand Up @@ -306,6 +316,29 @@ function NoUnsealedSectorLink() {
</div>
}

function NoUnsealedSectorLink() {
const {loading, error, data} = useQuery(FlaggedPiecesCountQuery, {
pollInterval: 10000,
variables: {
hasUnsealedCopy: false,
},
fetchPolicy: 'network-only',
})

if (error) return <div>Error: {error.message}</div>
if (loading) {
return <div>&nbsp;</div>
}

if (!data.piecesFlaggedCount) {
return null
}

return <div>
<Link className="nav-link" to="/no-unsealed">See {data.piecesFlaggedCount} pieces with no unsealed copy ➜</Link>
</div>
}

function FlaggedPieceRow({piece}) {
return <tr>
<td>
Expand All @@ -314,7 +347,7 @@ function FlaggedPieceRow({piece}) {
</Link>
</td>
<td>{piece.IndexStatus.Status}</td>
<td>{piece.DealCount}</td>
<td>{piece.Deals.length}</td>
</tr>
}

Expand Down Expand Up @@ -369,6 +402,12 @@ function NoUnsealedSectorPieces() {
const totalCount = data.piecesFlagged.totalCount
const moreRows = data.piecesFlagged.more

if (!totalCount) {
return <div className="flagged-pieces-none">
Boost doctor did not find any pieces that were flagged because there is no unsealed copy of the sector
</div>
}

var cursor = params.cursor
if (pageNum === 1 && rows.length) {
cursor = rows[0].CreatedAt.getTime()
Expand All @@ -390,32 +429,24 @@ function NoUnsealedSectorPieces() {
Pieces with no unsealed sector ({totalCount})
</h3>

{ totalCount ? (
<>
<table>
<tbody>
<tr>
<th>Piece CID</th>
<th>Index</th>
<th>Deals</th>
</tr>
<table>
<tbody>
<tr>
<th>Piece CID</th>
<th>Index</th>
<th>Deals</th>
</tr>

{rows.map(piece => (
<FlaggedPieceRow
key={piece.PieceCid}
piece={piece}
/>
))}
</tbody>
</table>
{rows.map(piece => (
<FlaggedPieceRow
key={piece.Piece.PieceCid}
piece={piece.Piece}
/>
))}
</tbody>
</table>

<Pagination {...paginationParams} />
</>
) : (
<div className="flagged-pieces-none">
Boost doctor did not find any pieces with no unsealed sector
</div>
)}
<Pagination {...paginationParams} />
</div>
}

Expand All @@ -433,6 +464,10 @@ function FlaggedPiecesLink() {
return <div>&nbsp;</div>
}

if (!data.piecesFlaggedCount) {
return null
}

return <div>
<Link className="nav-link" to="/piece-doctor">See {data.piecesFlaggedCount} flagged pieces ➜</Link>
</div>
Expand Down
11 changes: 9 additions & 2 deletions react/src/gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ const PiecesWithPayloadCidQuery = gql`
`;

const FlaggedPiecesQuery = gql`
query AppFlaggedPiecesQuery($cursor: BigInt, $offset: Int, $limit: Int) {
piecesFlagged(cursor: $cursor, offset: $offset, limit: $limit) {
query AppFlaggedPiecesQuery($hasUnsealedCopy: Boolean, $cursor: BigInt, $offset: Int, $limit: Int) {
piecesFlagged(hasUnsealedCopy: $hasUnsealedCopy, cursor: $cursor, offset: $offset, limit: $limit) {
pieces {
CreatedAt
Piece {
Expand All @@ -424,6 +424,12 @@ const FlaggedPiecesQuery = gql`
}
`;

const FlaggedPiecesCountQuery = gql`
query AppFlaggedPiecesCountQuery($hasUnsealedCopy: Boolean) {
piecesFlaggedCount(hasUnsealedCopy: $hasUnsealedCopy)
}
`;

const PieceBuildIndexMutation = gql`
mutation AppPieceBuildIndexMutation($pieceCid: String!) {
pieceBuildIndex(pieceCid: $pieceCid)
Expand Down Expand Up @@ -746,6 +752,7 @@ export {
PieceBuildIndexMutation,
PieceStatusQuery,
FlaggedPiecesQuery,
FlaggedPiecesCountQuery,
LIDQuery,
StorageQuery,
LegacyStorageQuery,
Expand Down

0 comments on commit a3c76b0

Please sign in to comment.