<query-mapping package='AWA.Blogs.Models'>
    <description>
      Several queries to collect statistics about posts.
    </description>

    <class name="AWA.Blogs.Models.Month_Stat_Info" bean="yes">
        <comment>The month statistics.</comment>
        <property type='Natural' name="year">
            <comment>the post identifier.</comment>
        </property>
        <property type='Natural' name="month">
            <comment>the post title.</comment>
        </property>
        <property type='Natural' name="count">
            <comment>the post uri.</comment>
        </property>
    </class>

    <query name='post-publish-stats'>
       <comment>Get statistics about the post publication on a blog.</comment>
       <sql>
    SELECT
      YEAR(p.publish_date) AS Y,
      MONTH(p.publish_date) AS M,
      COUNT(p.id)
    FROM awa_post AS p
    INNER JOIN awa_acl AS acl ON acl.entity_id = :blog_id AND acl.entity_type = :table AND acl.user_id = :user_id
    WHERE
      p.blog_id = :blog_id AND p.status > 0
    GROUP BY Y, M ORDER BY Y, M
       </sql>
    </query>

    <query name='post-access-stats'>
       <comment>Get statistics about the post publication on a blog.</comment>
       <sql>
    SELECT
      cnt.date,
      cnt.counter
    FROM awa_counter AS cnt
    INNER JOIN awa_counter_definition AS def ON def.entity_type = :entity_type AND cnt.definition_id = def.id AND def.name = :counter_name
    INNER JOIN awa_post AS post ON post.id = :entity_id
    WHERE
      cnt.object_id = :entity_id AND
      cnt.date &gt;= :first_date AND cnt.date &lt;= :last_date
       </sql>
    </query>

</query-mapping>

Define queries to collect statistics about the post access
Define queries to collect statistics about the post access
