<?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="com.microservices.dss.projects.mapper.CommitsMapper">
    <resultMap id="BaseResultMap" type="com.microservices.dss.projects.domain.Commits">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="repository_id" property="repositoryId" jdbcType="INTEGER" />
        <result column="version" property="version" jdbcType="VARCHAR" />
        <result column="committer" property="committer" jdbcType="VARCHAR" />
        <result column="committed_on" property="committedOn" jdbcType="TIMESTAMP" />
        <result column="project_id" property="projectId" jdbcType="INTEGER" />
        <result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
        <result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
    </resultMap>

    <select id="selectTotalCommitCount" resultType="java.lang.Integer">
        select count(*)
        from commit_logs
    </select>

    <select id="getNewCodeSubmissionTimesByMonth" parameterType="java.lang.String" resultType="java.util.HashMap">
        SELECT
            DATE_FORMAT(created_at, '%Y-%m') AS createTime,
            COUNT(*) AS num
        FROM
            commit_logs
        WHERE
            created_at &gt;= #{startTime,jdbcType=VARCHAR}
          AND created_at &lt;= #{endTime,jdbcType=VARCHAR}
        GROUP BY DATE_FORMAT(created_at, '%Y-%m')
    </select>
</mapper>