<?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.PullRequestsMapper">
    <resultMap id="BaseResultMap" type="com.microservices.dss.projects.domain.PullRequests">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="pull_request_id" property="pullRequestId" jdbcType="INTEGER" />
        <result column="gpid" property="gpid" jdbcType="INTEGER" />
        <result column="user_id" property="userId" jdbcType="INTEGER" />
        <result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
        <result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
        <result column="status" property="status" jdbcType="INTEGER" />
        <result column="project_id" property="projectId" jdbcType="INTEGER" />
        <result column="title" property="title" jdbcType="VARCHAR" />
        <result column="milestone" property="milestone" jdbcType="INTEGER" />
        <result column="head" property="head" jdbcType="VARCHAR" />
        <result column="base" property="base" jdbcType="VARCHAR" />
        <result column="issue_id" property="issueId" jdbcType="INTEGER" />
        <result column="fork_project_id" property="forkProjectId" jdbcType="INTEGER" />
        <result column="is_original" property="isOriginal" jdbcType="BIT" />
        <result column="comments_count" property="commentsCount" jdbcType="INTEGER" />
        <result column="commits_count" property="commitsCount" jdbcType="INTEGER" />
        <result column="files_count" property="filesCount" jdbcType="INTEGER" />
    </resultMap>


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

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