From fe6413b7754a896c9b133758b48fb0aba1f8538d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 31 Jul 2024 13:52:17 +0200 Subject: [PATCH] fix the resume button in sector info UI (#131) --- web/api/webrpc/sector.go | 45 +++---------------------- web/static/pages/sector/sector-info.mjs | 4 +-- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/web/api/webrpc/sector.go b/web/api/webrpc/sector.go index a00d38168..b194a516f 100644 --- a/web/api/webrpc/sector.go +++ b/web/api/webrpc/sector.go @@ -408,60 +408,25 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto Resumable: hasAnyStuckTask, }, nil - - //a.executePageTemplate(w, "sector_info", "Sector Info", mi) } -func (a *WebRPC) SectorResume(ctx context.Context, sp, id string) error { - intid, err := strconv.ParseInt(id, 10, 64) - if err != nil { - return xerrors.Errorf("invalid id") - } - - maddr, err := address.NewFromString(sp) - if err != nil { - return xerrors.Errorf("invalid sp") - } - - spid, err := address.IDFromAddress(maddr) - if err != nil { - return xerrors.Errorf("invalid sp") - } - - // call CREATE OR REPLACE FUNCTION unset_task_id(sp_id_param bigint, sector_number_param bigint) - - _, err = a.deps.DB.Exec(ctx, `SELECT unset_task_id($1, $2)`, spid, intid) +func (a *WebRPC) SectorResume(ctx context.Context, spid, id int) error { + _, err := a.deps.DB.Exec(ctx, `SELECT unset_task_id($1, $2)`, spid, id) if err != nil { return xerrors.Errorf("failed to resume sector: %w", err) } return nil } -func (a *WebRPC) SectorRemove(ctx context.Context, sp, id string) error { - - intid, err := strconv.ParseInt(id, 10, 64) - if err != nil { - return xerrors.Errorf("invalid id") - } - - maddr, err := address.NewFromString(sp) - if err != nil { - return xerrors.Errorf("invalid sp") - } - - spid, err := address.IDFromAddress(maddr) - if err != nil { - return xerrors.Errorf("invalid sp") - } - - _, err = a.deps.DB.Exec(ctx, `DELETE FROM sectors_sdr_pipeline WHERE sp_id = $1 AND sector_number = $2`, spid, intid) +func (a *WebRPC) SectorRemove(ctx context.Context, spid, id int) error { + _, err := a.deps.DB.Exec(ctx, `DELETE FROM sectors_sdr_pipeline WHERE sp_id = $1 AND sector_number = $2`, spid, id) if err != nil { return xerrors.Errorf("failed to resume sector: %w", err) } _, err = a.deps.DB.Exec(ctx, `INSERT INTO storage_removal_marks (sp_id, sector_num, sector_filetype, storage_id, created_at, approved, approved_at) SELECT miner_id, sector_num, sector_filetype, storage_id, current_timestamp, FALSE, NULL FROM sector_location - WHERE miner_id = $1 AND sector_num = $2`, spid, intid) + WHERE miner_id = $1 AND sector_num = $2`, spid, id) if err != nil { return xerrors.Errorf("failed to mark sector for removal: %w", err) } diff --git a/web/static/pages/sector/sector-info.mjs b/web/static/pages/sector/sector-info.mjs index b2f55b173..11db50c62 100644 --- a/web/static/pages/sector/sector-info.mjs +++ b/web/static/pages/sector/sector-info.mjs @@ -34,9 +34,9 @@ customElements.define('sector-info',class SectorInfo extends LitElement {
Remove ${!this.data.PipelinePoRep?.Failed ? '(THIS SECTOR IS NOT FAILED!)' : ''} - +
- ${this.data.Resumable ? html`` : ''} + ${this.data.Resumable ? html`` : ''}

PoRep Pipeline