Created
June 7, 2018 16:55
-
-
Save fmcgeough/6288130e4b51c5330c48866ccfbb056c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @doc """ | |
| Returns true if Jira exists, else false. | |
| """ | |
| def ticket_exists?(key) do | |
| {project, jira_num} = split_jira(key) | |
| from( | |
| j in JiraIssue, | |
| join: p in assoc(j, :jira_project), | |
| where: p.pkey == ^project and j.issuenum == ^jira_num, | |
| select: count(p.id) | |
| ) | |
| |> JiraRepo.one() | |
| |> case do | |
| 1 -> true | |
| _ -> false | |
| end | |
| end | |
| def ticket_summary(key) do | |
| {project, jira_num} = split_jira(key) | |
| from( | |
| j in JiraIssue, | |
| join: p in assoc(j, :jira_project), | |
| where: p.pkey == ^project and j.issuenum == ^jira_num, | |
| select: [j.id] | |
| ) | |
| |> JiraRepo.all() | |
| end | |
| output from ticket_summary call : | |
| iex(13)> Jira.ticket_summary("PCR-354") | |
| [debug] QUERY OK source="jiraissue" db=46.2ms queue=0.2ms | |
| SELECT j0.`id` FROM `jiraissue` AS j0 INNER JOIN `project` AS p1 ON p1.`id` = j0.`project` WHERE ((p1.`pkey` = ?) AND (j0.`issuenum` = ?)) ["PCR", #Decimal<354>] | |
| %{} | |
| iex(14)> Jira.ticket_exists?("PCR-354") | |
| [debug] QUERY OK source="jiraissue" db=47.3ms | |
| SELECT count(p1.`id`) FROM `jiraissue` AS j0 INNER JOIN `project` AS p1 ON p1.`id` = j0.`project` WHERE ((p1.`pkey` = ?) AND (j0.`issuenum` = ?)) ["PCR", #Decimal<354>] | |
| true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment