private string GetJql(string searchText) { var projectQuery = string.Empty; var nonProjectText = string.Empty; foreach (var keyword in searchText.Split(' ')) { var firstProjectMatch = jiraProjectCodeCache.FirstOrDefault(x => x == keyword); if (firstProjectMatch != null) { if (!string.IsNullOrWhiteSpace(projectQuery)) { projectQuery += " OR "; } projectQuery += $"project = \"{firstProjectMatch}\""; } else { nonProjectText += $" {keyword}"; } } nonProjectText = nonProjectText.Trim(); var keyQuery = string.Empty; try { if (searchText.Contains("-") && (recentJiraCollection.GetRecentJiraCollection().Any(x => x.JiraReference == searchText) || jira.GetIssue(searchText) != null)) { keyQuery = $"(key = \"{searchText}\")"; } } catch { /*ignored*/ } var jql = string.Empty; if (!string.IsNullOrWhiteSpace(nonProjectText)) { jql = string.IsNullOrWhiteSpace(jql) ? $"(Summary ~ \"{nonProjectText}\" OR Description ~ \"{nonProjectText}\")" : $"({jql}) AND (Summary ~ \"{nonProjectText}\" OR Description ~ \"{nonProjectText}\")"; } if (!string.IsNullOrWhiteSpace(projectQuery)) { jql = string.IsNullOrWhiteSpace(jql) ? $"({projectQuery})" : $"({jql}) AND ({projectQuery})"; } if (!string.IsNullOrWhiteSpace(keyQuery)) { jql = string.IsNullOrWhiteSpace(jql) ? $"({keyQuery})" : $"({jql}) OR ({keyQuery})"; } return(jql); }
public IEnumerable <RecentJira> GetRecentJirasFound() { return(recentJiraCollection.GetRecentJiraCollection()); }