<commit_before><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 

<mapper namespace="summaryOrganization">
	
    <sql id="selectAllTimeSummary">
        TO_CHAR(all_time_summary) organization_summary,
        all_time_last_result last_result,
        all_time_site_count site_count,
        all_time_activity_count activity_count
    </sql>
    
    <sql id="selectCurrentYearSummary">
        TO_CHAR(current_year_summary) organization_summary,
        current_year_last_result last_result,
        current_year_site_count site_count,
        current_year_activity_count activity_count
    </sql>
    
    <sql id="selectFiveYearSummary">
        TO_CHAR(five_year_summary) organization_summary,
        five_year_last_result last_result,
        five_year_site_count site_count,
        five_year_activity_count activity_count
    </sql>
    
    <sql id="selectSummaryByYear">
        <choose>
            <when test="summaryYears == null or summaryYears.equalsIgnoreCase('all')"><include refid="selectAllTimeSummary" /></when>
            <otherwise>
                <choose>
                    <when test="summaryYears.equalsIgnoreCase('1')"><include refid="selectCurrentYearSummary" /></when>
                    <when test="summaryYears.equalsIgnoreCase('5')"><include refid="selectFiveYearSummary" /></when>
                    <otherwise><include refid="selectAllTimeSummary" /></otherwise>
                </choose>
            </otherwise>
        </choose>
    </sql>
	
    <sql id="summaryYearWhere">
        <where>
            <if test="organization != null">
                organization in <foreach item="i" collection="organization" open="(" separator="," close=")">#{i}</foreach>
                <choose>
                    <when test="summaryYears == null or summaryYears.equalsIgnoreCase('all')">
                        and all_time_summary is not null
                    </when>
                    <otherwise>
                        <choose>
                            <when test="summaryYears.equalsIgnoreCase('1')">and current_year_summary is not null</when>
                            <when test="summaryYears.equalsIgnoreCase('5')">and five_year_summary is not null</when>
                            <otherwise>and all_time_summary is not null</otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
        </where>
    </sql>

    <select id="select" resultType="java.util.LinkedHashMap" fetchSize="500">

    SELECT

    organization,
    organization_name,
    nvl2(organization_wqp_url, #{siteUrlBase, jdbcType=VARCHAR} || organization_url, null) organization_wqp_url,
    <include refid="selectSummaryByYear" />

    FROM

    organization_sum

    <include refid="summaryYearWhere" />
    </select>

	<select id="count" resultType="java.util.LinkedHashMap">
        select data_source, count(*) organization_sum_count
          from (select organization_sum.data_source,
                       organization_sum.organization_id
                  <include refid="summaryYearWhere" />)
             group by rollup(data_source)
    </select>
	
</mapper><commit_msg>Got rid of TO_CHAR<commit_after><?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 

<mapper namespace="summaryOrganization">
	
    <sql id="selectAllTimeSummary">
        all_time_summary organization_summary,
        all_time_last_result last_result,
        all_time_site_count site_count,
        all_time_activity_count activity_count
    </sql>
    
    <sql id="selectCurrentYearSummary">
        current_year_summary organization_summary,
        current_year_last_result last_result,
        current_year_site_count site_count,
        current_year_activity_count activity_count
    </sql>
    
    <sql id="selectFiveYearSummary">
        five_year_summary organization_summary,
        five_year_last_result last_result,
        five_year_site_count site_count,
        five_year_activity_count activity_count
    </sql>
    
    <sql id="selectSummaryByYear">
        <choose>
            <when test="summaryYears == null or summaryYears.equalsIgnoreCase('all')"><include refid="selectAllTimeSummary" /></when>
            <otherwise>
                <choose>
                    <when test="summaryYears.equalsIgnoreCase('1')"><include refid="selectCurrentYearSummary" /></when>
                    <when test="summaryYears.equalsIgnoreCase('5')"><include refid="selectFiveYearSummary" /></when>
                    <otherwise><include refid="selectAllTimeSummary" /></otherwise>
                </choose>
            </otherwise>
        </choose>
    </sql>
	
    <sql id="summaryYearWhere">
        <where>
            <if test="organization != null">
                organization in <foreach item="i" collection="organization" open="(" separator="," close=")">#{i}</foreach>
                <choose>
                    <when test="summaryYears == null or summaryYears.equalsIgnoreCase('all')">
                        and all_time_summary is not null
                    </when>
                    <otherwise>
                        <choose>
                            <when test="summaryYears.equalsIgnoreCase('1')">and current_year_summary is not null</when>
                            <when test="summaryYears.equalsIgnoreCase('5')">and five_year_summary is not null</when>
                            <otherwise>and all_time_summary is not null</otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
        </where>
    </sql>

    <select id="select" resultType="java.util.LinkedHashMap" fetchSize="500">

    SELECT

    organization,
    organization_name,
    nvl2(organization_url, #{siteUrlBase, jdbcType=VARCHAR} || organization_url, null) organization_wqp_url,
    <include refid="selectSummaryByYear" />

    FROM

    organization_sum

    <include refid="summaryYearWhere" />
    </select>

	<select id="count" resultType="java.util.LinkedHashMap">
        select data_source, count(*) organization_sum_count
          from (select organization_sum.data_source,
                       organization_sum.organization_id
                      from organization_sum
                  <include refid="summaryYearWhere" />)
             group by rollup(data_source)
    </select>
	
</mapper>
{'fraction_non_alphanumeric': 0.1094845989630985, 'fraction_numerical': 0.004269594388533089, 'mean_word_length': 2.2926706827309236, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 2, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3129967', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1736, 'n_words': 326}