Skip to content

Commit

Permalink
fixing bug that looked for priority and tracker enums in the wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Philion committed Oct 3, 2024
1 parent 9e6df77 commit 008be46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion netbot/cog_scn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions netbot/cog_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
}
Expand All @@ -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}")
Expand Down
8 changes: 0 additions & 8 deletions netbot/netbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions redmine/tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 008be46

Please sign in to comment.