async def update(self, ctx, build_id, *, msg=""): """Owner only - To be run after an update. Resolves all -P2 reports.""" if not ctx.message.author.id == constants.OWNER_ID: return changelog = DiscordEmbedTextPaginator() async for report_data in query( db.reports, Attr("pending").eq(True)): # find all pending=True reports report = Report.from_dict(report_data) await report.resolve(ctx, f"Patched in build {build_id}", ignore_closed=True) report.pending = False report.commit() action = "Fixed" if not report.is_bug: action = "Added" if report.get_issue_link(): changelog.add( f"- {action} [`{report.report_id}`]({report.get_issue_link()}) {report.title}" ) else: changelog.add( f"- {action} `{report.report_id}` {report.title}") changelog.add(msg) embed = discord.Embed(title=f"**Build {build_id}**", colour=0x87d37c) changelog.write_to(embed) await ctx.send(embed=embed) await ctx.message.delete()
async def pending_list(self, ctx): out = [] async for report_data in query(db.reports, Attr("pending").eq(True)): out.append(Report.from_dict(report_data).report_id) out = ', '.join(f"`{_id}`" for _id in out) await ctx.send(f"Pending reports: {out}")
def run(): with open("reports.json") as f: reports = json.load(f) for report_id, report in reports.items(): print(report_id) for attachment in report['attachments']: try: attachment['author'] = int(attachment['author']) except ValueError: pass attachment['message'] = attachment.pop('msg') new_report = Report.from_dict(report) try: new_report.reporter = int(new_report.reporter) except ValueError: pass if new_report.message: new_report.message = int(new_report.message) new_report.is_bug = new_report.report_id.startswith("AFR") new_report.subscribers = list(map(int, new_report.subscribers)) reports[report_id] = new_report.to_dict() with open("new-reports.json", 'w') as f: json.dump(reports, f)
async def update(ctx, build_id: int): """Owner only - To be run after an update. Resolves all -P2 reports.""" if not ctx.message.author.id == OWNER_ID: return changelog = f"**Build {build_id}**\n" for _id, raw_report in bot.db.jget("reports", {}).items(): report = Report.from_dict(raw_report) if not report.severity == -2: continue await report.resolve(ctx, f"Patched in build {build_id}") report.commit() changelog += f"- `{report.report_id}` {report.title}\n" await bot.send_message(ctx.message.channel, changelog) await bot.delete_message(ctx.message)
def test_create(): report = Report("1", "AVR-001", "test", 6, 0, [], None) assert report.reporter == "1" assert report.report_id == "AVR-001" assert report.title == "test" assert report.severity == 6 assert report.verification == 0 assert report.attachments == [] assert report.message is None report_dict = report.to_dict() new_report = Report.from_dict(report_dict) assert report.__dict__ == new_report.__dict__