Created
December 31, 2023 08:39
-
-
Save irsl/f6a656c19681a3dd234684734c404c62 to your computer and use it in GitHub Desktop.
This file contains 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
def issue_where_clause | |
repo_ids = params[:repos].present? ? params[:repos].split(",") : [] | |
if !repo_ids.empty? | |
"I.RepositoryId IN (#{repo_ids.join(', ')}) " | |
end | |
end | |
def ospo_issue_trend_data # rubocop:todo GitHub/UseRestfulActions | |
return render_404 unless this_organization.ospo_insights_enabled? | |
trend_data = [] | |
GitHub.dogstats.time("ospo_issue_trend.query", tags: []) do | |
issue_trend_query = <<-QUERY.squish | |
SELECT #{date_clause} , SUM(IssueEvent) as IssueCount , State | |
FROM ( | |
SELECT #{issue_cycle_clause} as DateKey, d.DateKey as Actualdate, 1 as IssueEvent, | |
CASE WHEN (d.DateKey < COALESCE(I.ClosedDateKey, d.DateKey + 1)) THEN 'Open' ELSE 'Closed' END as State | |
FROM Issue I | |
INNER JOIN Date d | |
ON I.CreatedDateKey < (d.DateKey + 1) | |
JOIN Repository r ON I.RepositoryId = r.RepositoryId | |
WHERE r.Active = 1 AND r.[Public] = 1 | |
AND d.DateKey #{date_selector} | |
AND r.AccountId = #{insights_get_organization_id} | |
AND #{issue_where_clause} | |
) AS OspoTrends | |
WHERE DateKey = Actualdate | |
GROUP BY DateKey, State | |
ORDER BY DateKey | |
QUERY | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment