diff --git a/netbot/cog_scn.py b/netbot/cog_scn.py index 8ba7196..6a4396c 100644 --- a/netbot/cog_scn.py +++ b/netbot/cog_scn.py @@ -216,7 +216,7 @@ async def sync(self, ctx:discord.ApplicationContext): ticket = self.redmine.ticket_mgr.create(user, message) # set tracker # TODO: search up all parents in hierarchy? - tracker = self.bot.lookup_tracker(thread.parent.name) + tracker = self.bot.redmine.ticket_mgr.get_tracker(thread.parent.name) if tracker: log.debug(f"found {thread.parent.name} => {tracker}") params = { diff --git a/netbot/cog_tickets.py b/netbot/cog_tickets.py index ed997cd..f614eb3 100644 --- a/netbot/cog_tickets.py +++ b/netbot/cog_tickets.py @@ -245,7 +245,7 @@ def resolve_query_term(self, term) -> list[Ticket]: # note: fall thru for empty result from team query. if term in CHANNEL_MAPPING: - tracker = self.bot.lookup_tracker(CHANNEL_MAPPING[term]) + tracker = self.bot.redmine.ticket_mgr.get_tracker(CHANNEL_MAPPING[term]) if tracker: result = self.redmine.ticket_mgr.tickets(tracker_id=tracker.id) log.debug(f"QQQ<: {result}") @@ -474,7 +474,7 @@ async def create_new_ticket(self, ctx: discord.ApplicationContext, title:str): # ticket created, set tracker # set tracker # TODO: search up all parents in hierarchy? - tracker = self.bot.lookup_tracker(channel_name) + tracker = self.bot.redmine.ticket_mgr.get_tracker(channel_name) if tracker: log.debug(f"found {channel_name} => {tracker}") params = { @@ -562,7 +562,7 @@ async def tracker(self, ctx: discord.ApplicationContext, ticket_id:int, tracker: ticket_link = self.bot.formatter.redmine_link(ticket) # look up the tracker string - tracker_rec = self.bot.lookup_tracker(tracker) + tracker_rec = self.bot.redmine.ticket_mgr.get_tracker(tracker) fields = { "tracker_id": tracker_rec.id, } @@ -583,7 +583,7 @@ async def priority(self, ctx: discord.ApplicationContext, ticket_id:int, priorit ticket = self.redmine.ticket_mgr.get(ticket_id) if ticket: # look up the priority - priority = self.bot.lookup_priority(priority_str) + priority = self.bot.redmine.ticket_mgr.get_priority(priority_str) if priority is None: log.error(f"Unknown priority: {priority_str}") await ctx.respond(f"Unknown priority: {priority_str}") diff --git a/netbot/netbot.py b/netbot/netbot.py index 7cf133e..c54da9c 100755 --- a/netbot/netbot.py +++ b/netbot/netbot.py @@ -391,14 +391,6 @@ async def check_expired_tickets(self): self.expire_expired_tickets() - def lookup_tracker(self, tracker:str) -> NamedId: - return self.trackers.get(tracker, None) - - - def lookup_priority(self, priority:str) -> NamedId: - return self.priorities.get(priority, None) - - def find_ticket_thread(self, ticket_id:int) -> discord.Thread|None: """Search thru thread titles looking for a matching ticket ID""" # search thru all threads for: diff --git a/redmine/tickets.py b/redmine/tickets.py index 4a4da1a..a569300 100644 --- a/redmine/tickets.py +++ b/redmine/tickets.py @@ -21,6 +21,7 @@ SCN_PROJECT_ID = "1" # could lookup scn in projects INTAKE_TEAM = "ticket-intake" INTAKE_TEAM_ID = 19 # FIXME +EPIC_PRIORITY_NAME = "EPIC" TICKET_MAX_AGE = 4 * 7 # 4 weeks; 28 days @@ -261,9 +262,14 @@ def get_tickets(self, ticket_ids: list[int], **params) -> list[Ticket]: def get_epics(self) -> list[Ticket]: """Get all the open epics, organized by tracker""" # query tickets pri = epic - epic_priority = self.get_priority("EPIC") + epic_priority = self.get_priority(EPIC_PRIORITY_NAME) + + if not epic_priority: + # very unexpected + log.error(f"Cannot find expected {EPIC_PRIORITY_NAME} priority! Can't find epics!") + log.debug(f"known priorities: {self.priorities}") + return [] - #response = self.session.get(f"/issues.json?priority_id={epic_priority_id}&include=children&limit=10&sort={DEFAULT_SORT}") epics = self.tickets(priority_id=epic_priority.id, limit=10, sort=DEFAULT_SORT) for epic in epics: # get the sub-tickets for the epic (both open and closed)