Search in sources :

Example 1 with ClientUsagePerApiHandler

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

the class JdbcMetricsAccessor method getClientUsagePerApi.

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

Aggregations

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