mojira-discord-bot icon indicating copy to clipboard operation
mojira-discord-bot copied to clipboard

Add support for search command arguments and JQL queries

Open dericksonmark opened this issue 2 years ago • 0 comments

Purpose

A much better (I think) version of #241. This allows arguments and JQL queries to be used within the !jira search command. This also fixes up a few other things with the search command, such as the "No results found" message not being displayed when no results were found as a result of executing a search. Additionally, this adds the JQL query used into the embed, and adds the total number of results found into the title of the embed.

Approach

First, the modifiers are grouped together. Then, if one of the modifiers is :jql, the text following it is used as the JQL query. However, if :jql is not present, the modifiers will be used in building the query. A modifier is built with a hyphen or an underscore preceding a field name or a field shortcut (for fields like Mojang Priority, this is "mp" [these have been manually added in the config]). When using an underscore, the modifier is directly paired with its argument. However, when using a hyphen, the modifier is paired with its argument, and then the clause is negated. Finally, any text not part of a modifier is treated as text ~ <content>, allowing classic search features to continue to function.

Additionally, some custom search clauses have been implemented:

  • _commenter uses issueFunction in commented("by <arg>")
  • _transitionedby uses status changed by <arg>

Searches are automatically ordered by created, updated DESC.

An example of a valid command: !jira search _transitionedby violine1101 -resolution Unresolved _commenter "Darth Cobby" This searches with this query: status changed by violine1101 AND resolution != Unresolved AND issueFunction in commented("by \"Darth Cobby\"") ORDER BY created, updated DESC

dericksonmark avatar May 13 '22 21:05 dericksonmark