Search in sources :

Example 1 with UsagePerClientHandler

use of io.apiman.manager.api.jdbc.handlers.UsagePerClientHandler in project apiman by apiman.

the class JdbcMetricsAccessor method getUsagePerClient.

/**
 * @see io.apiman.manager.api.core.IMetricsAccessor#getUsagePerClient(java.lang.String, java.lang.String, java.lang.String, org.joda.time.DateTime, org.joda.time.DateTime)
 */
@Override
public UsagePerClientBean getUsagePerClient(String organizationId, String apiId, String version, DateTime from, DateTime to) {
    try {
        QueryRunner run = new QueryRunner(ds);
        // $NON-NLS-1$
        String sql = "SELECT client_id, count(*) FROM gw_requests WHERE api_org_id = ? AND api_id = ? AND api_version = ? AND rstart >= ? AND rstart < ? GROUP BY client_id";
        ResultSetHandler<UsagePerClientBean> handler = new UsagePerClientHandler();
        return run.query(sql, handler, organizationId, apiId, version, from.getMillis(), to.getMillis());
    } catch (SQLException e) {
        e.printStackTrace();
        return new UsagePerClientBean();
    }
}
Also used : UsagePerClientHandler(io.apiman.manager.api.jdbc.handlers.UsagePerClientHandler) SQLException(java.sql.SQLException) UsagePerClientBean(io.apiman.manager.api.beans.metrics.UsagePerClientBean) QueryRunner(org.apache.commons.dbutils.QueryRunner)

Aggregations

UsagePerClientBean (io.apiman.manager.api.beans.metrics.UsagePerClientBean)1 UsagePerClientHandler (io.apiman.manager.api.jdbc.handlers.UsagePerClientHandler)1 SQLException (java.sql.SQLException)1 QueryRunner (org.apache.commons.dbutils.QueryRunner)1