<commit_before>-- BLOCK issues_count
WITH counts AS (
    SELECT
        i.open,
        count(*)::int
    FROM
        issues AS i
    WHERE
        i.course_id = $course_id
        AND i.course_caused
    GROUP BY i.open
)
SELECT
    open,
    coalesce(count, 0) AS count
FROM
    (VALUES (true), (false)) AS tmp(open)
    LEFT JOIN counts USING (open)
ORDER BY open;

-- BLOCK select_issues
SELECT
    i.id AS issue_id,
    format_date_full_compact(now(), coalesce(ci.display_timezone, c.display_timezone)) AS now_date,
    format_date_full_compact(i.date, coalesce(ci.display_timezone, c.display_timezone)) AS formatted_date,
    ci.short_name AS course_instance_short_name,
    CASE WHEN i.assessment_id IS NOT NULL THEN assessments_format(i.assessment_id) ELSE NULL END AS assessment,
    i.question_id,
    q.directory AS question_qid,
    u.uid AS user_uid,
    i.student_message,
    i.variant_id,
    i.open,
    i.manually_reported
FROM
    issues_select_with_filter (
        $filter_is_open,
        $filter_is_closed,
        $filter_manually_reported,
        $filter_automatically_reported,
        $filter_qids,<commit_msg>Query time in ISO8601 to fix Moment warning<commit_after>-- BLOCK issues_count
WITH counts AS (
    SELECT
        i.open,
        count(*)::int
    FROM
        issues AS i
    WHERE
        i.course_id = $course_id
        AND i.course_caused
    GROUP BY i.open
)
SELECT
    open,
    coalesce(count, 0) AS count
FROM
    (VALUES (true), (false)) AS tmp(open)
    LEFT JOIN counts USING (open)
ORDER BY open;

-- BLOCK select_issues
SELECT
    i.id AS issue_id,
    format_date_iso8601(now(), coalesce(ci.display_timezone, c.display_timezone)) AS now_date,
    format_date_iso8601(i.date, coalesce(ci.display_timezone, c.display_timezone)) AS formatted_date,
    ci.short_name AS course_instance_short_name,
    CASE WHEN i.assessment_id IS NOT NULL THEN assessments_format(i.assessment_id) ELSE NULL END AS assessment,
    i.question_id,
    q.directory AS question_qid,
    u.uid AS user_uid,
    i.student_message,
    i.variant_id,
    i.open,
    i.manually_reported
FROM
    issues_select_with_filter (
        $filter_is_open,
        $filter_is_closed,
        $filter_manually_reported,
        $filter_automatically_reported,
        $filter_qids,
{'fraction_non_alphanumeric': 0.0791304347826087, 'fraction_numerical': 0.00608695652173913, 'mean_word_length': 2.9947916666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3859754', 'n_tokens_mistral': 817, 'n_tokens_neox': 767, 'n_words': 188}