Proposal Migration Script - Delete Stale Drafts (#104)
* fix admin tsc check * delete stale drafts
This commit is contained in:
parent
dc09690ea3
commit
b02e14a42f
|
@ -195,7 +195,7 @@ async function fetchCCRs(params: Partial<PageQuery>) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteCCR(id: number) {
|
export async function deleteCCR(id: number) {
|
||||||
await api.delete(`/admin/ccrs/${id}`);
|
await api.delete(`/admin/ccrs/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ const app = store({
|
||||||
resetCCRPageQuery() {
|
resetCCRPageQuery() {
|
||||||
resetPageParams(app.ccrs);
|
resetPageParams(app.ccrs);
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchCCRDetail(id: number) {
|
async fetchCCRDetail(id: number) {
|
||||||
app.ccrDetailFetching = true;
|
app.ccrDetailFetching = true;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -98,6 +98,7 @@ def retire_v1_proposals(dry):
|
||||||
modified_draft_count = 0
|
modified_draft_count = 0
|
||||||
modified_pending_count = 0
|
modified_pending_count = 0
|
||||||
modified_staking_count = 0
|
modified_staking_count = 0
|
||||||
|
deleted_draft_count = 0
|
||||||
|
|
||||||
if not proposals_funding_required and not proposals_draft and not proposals_pending and not proposals_staking:
|
if not proposals_funding_required and not proposals_draft and not proposals_pending and not proposals_staking:
|
||||||
print("No proposals found. Exiting...")
|
print("No proposals found. Exiting...")
|
||||||
|
@ -134,11 +135,11 @@ def retire_v1_proposals(dry):
|
||||||
|
|
||||||
if not dry:
|
if not dry:
|
||||||
# reset target because v2 estimates are in USD
|
# reset target because v2 estimates are in USD
|
||||||
proposal.target = 0
|
proposal.target = '0'
|
||||||
proposal.version = '2'
|
proposal.version = '2'
|
||||||
proposal.stage = ProposalStage.PREVIEW
|
proposal.stage = ProposalStage.PREVIEW
|
||||||
proposal.status = ProposalStatus.DRAFT
|
proposal.status = ProposalStatus.DRAFT
|
||||||
db.session.add(p)
|
db.session.add(proposal)
|
||||||
|
|
||||||
for m in milestones:
|
for m in milestones:
|
||||||
# clear date estimated because v2 proposals use days_estimated (date_estimated is dynamically set)
|
# clear date estimated because v2 proposals use days_estimated (date_estimated is dynamically set)
|
||||||
|
@ -147,7 +148,26 @@ def retire_v1_proposals(dry):
|
||||||
|
|
||||||
print(f"Modified {len(milestones)} milestones on proposal {p.id}")
|
print(f"Modified {len(milestones)} milestones on proposal {p.id}")
|
||||||
|
|
||||||
|
# delete drafts that have no content
|
||||||
|
def delete_stale_draft(proposal):
|
||||||
|
if proposal.title or proposal.brief or proposal.content or proposal.category or proposal.target != "0":
|
||||||
|
return False
|
||||||
|
|
||||||
|
if proposal.payout_address or proposal.milestones:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not dry:
|
||||||
|
db.session.delete(proposal)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
for p in proposals_draft:
|
for p in proposals_draft:
|
||||||
|
is_stale = delete_stale_draft(p)
|
||||||
|
if is_stale:
|
||||||
|
deleted_draft_count += 1
|
||||||
|
print(f"Deleted stale 'DRAFT' proposal {p.id} - {p.title}")
|
||||||
|
continue
|
||||||
|
|
||||||
convert_proposal_to_v2_draft(p)
|
convert_proposal_to_v2_draft(p)
|
||||||
modified_draft_count += 1
|
modified_draft_count += 1
|
||||||
print(f"Modified 'DRAFT' proposal {p.id} - {p.title}")
|
print(f"Modified 'DRAFT' proposal {p.id} - {p.title}")
|
||||||
|
@ -171,5 +191,6 @@ def retire_v1_proposals(dry):
|
||||||
print(f"Modified {modified_draft_count} 'DRAFT' proposals")
|
print(f"Modified {modified_draft_count} 'DRAFT' proposals")
|
||||||
print(f"Modified {modified_pending_count} 'PENDING' proposals")
|
print(f"Modified {modified_pending_count} 'PENDING' proposals")
|
||||||
print(f"Modified {modified_staking_count} 'STAKING' proposals")
|
print(f"Modified {modified_staking_count} 'STAKING' proposals")
|
||||||
|
print(f"Deleted {deleted_draft_count} stale 'DRAFT' proposals")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue