mojira / mojira-discord-bot

🎮 A Discord bot for linking to and providing information about Mojira tickets
https://discord.gg/rpCyfKV
GNU General Public License v3.0
19 stars 9 forks source link

Add support for search command arguments and JQL queries #261

Open dericksonmark opened 2 years ago

dericksonmark commented 2 years ago

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:

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