/* SELECT statements */
#define SELECT_FOR_PERIOD "select binpath, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, " \
- "sum(sent) as sent, imsi, ground, iftype, ifname from statistics " \
+ "sum(sent) as sent, subscriber_id, ground, iftype, ifname from statistics " \
"where time_stamp between ? and ? " \
- "group by binpath, is_roaming, imsi order by received desc"
+ "group by binpath, is_roaming, subscriber_id order by received desc"
#define SELECT_FOR_PERIOD_IFACE "select binpath, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, " \
- "sum(sent) as sent, imsi, ground, iftype, ifname from statistics " \
+ "sum(sent) as sent, subscriber_id, ground, iftype, ifname from statistics " \
"where time_stamp between ? and ? " \
- "and iftype=? group by binpath, is_roaming, imsi order by received desc"
+ "and iftype=? group by binpath, is_roaming, subscriber_id order by received desc"
#define SELECT_CHUNKS "select binpath, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, " \
- "sum(sent) as sent, imsi, ground, iftype, ifname, " \
+ "sum(sent) as sent, subscriber_id, ground, iftype, ifname, " \
"time_stamp - time_stamp % ? as timestamp " \
"from statistics where time_stamp between ? and ? " \
- "group by binpath, timestamp, imsi order by timestamp"
+ "group by binpath, timestamp, subscriber_id order by timestamp"
#define SELECT_CHUNKS_IFACE "select binpath, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, " \
- "sum(sent) as sent, imsi, ground, iftype, ifname, " \
+ "sum(sent) as sent, subscriber_id, ground, iftype, ifname, " \
"time_stamp - time_stamp % ? as timestamp " \
"from statistics where time_stamp between ? and ? and iftype=?" \
- "group by binpath, timestamp, imsi order by timestamp"
+ "group by binpath, timestamp, subscriber_id order by timestamp"
#define SELECT_APP_DETAILS "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground from statistics " \
+ "ifname, subscriber_id, ground from statistics " \
"where time_stamp between ? and ? and binpath=? " \
- "group by binpath, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "group by binpath, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming " \
- "order by time_stamp, binpath, iftype, ifname, imsi, " \
+ "order by time_stamp, binpath, iftype, ifname, subscriber_id, " \
"hw_net_protocol_type, is_roaming"
#define SELECT_APP_DETAILS_IFACE "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground from statistics " \
+ "ifname, subscriber_id, ground from statistics " \
"where time_stamp between ? and ? and binpath=? and iftype=?" \
- "group by hw_net_protocol_type, is_roaming, iftype, ifname, imsi " \
+ "group by hw_net_protocol_type, is_roaming, iftype, ifname, subscriber_id " \
"order by time_stamp, hw_net_protocol_type, is_roaming, iftype, " \
- "ifname, imsi"
+ "ifname, subscriber_id"
#define SELECT_CHUNKS_APP "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground, time_stamp - time_stamp % ? as time_stamp " \
+ "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \
"from statistics " \
"group by iftype, ifname, time_stamp, hw_net_protocol_type, is_roaming " \
"order by time_stamp, iftype, ifname, hw_net_protocol_type, is_roaming"
#define SELECT_CHUNKS_APP_IFACE "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground, time_stamp - time_stamp % ? as time_stamp " \
+ "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \
"from statistics where time_stamp between ? and ? and binpath = ? " \
"and iftype = ? " \
"group by time_stamp, hw_net_protocol_type, is_roaming, " \
- "iftype, ifname, imsi " \
- "order by time_stamp, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "iftype, ifname, subscriber_id " \
+ "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming"
#define SELECT_TOTAL "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground from statistics " \
- " where (time_stamp between ? and ?) and binpath != 'TOTAL_DATACALL' " \
- "and binpath != 'TOTAL_WIFI' and binpath != 'TOTAL_BLUETOOTH' " \
- "and binpath != 'TOTAL_IPV4' and binpath != 'TOTAL_IPV6' " \
- "group by iftype, ifname, imsi, hw_net_protocol_type, is_roaming " \
- "order by time_stamp, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "ifname, subscriber_id, ground from statistics " \
+ "where (time_stamp between ? and ?) " \
+ "and binpath NOT LIKE 'TOTAL_%' " \
+ "group by iftype, ifname, subscriber_id, hw_net_protocol_type, is_roaming " \
+ "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming"
#define SELECT_TOTAL_IFACE "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground from statistics " \
- " where (time_stamp between ? and ?) " \
- "and iftype=? " \
+ "ifname, subscriber_id, ground from statistics " \
+ "where (time_stamp between ? and ?) and iftype=? " \
+ "and binpath NOT LIKE 'TOTAL_%' " \
"group by hw_net_protocol_type, is_roaming, " \
- "iftype, ifname, imsi " \
- "order by time_stamp, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "iftype, ifname, subscriber_id " \
+ "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming"
#define SELECT_CHUNKS_TOTAL "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground, time_stamp - time_stamp % ? as time_stamp " \
+ "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \
"from statistics where time_stamp between ? and ? " \
- "group by time_stamp, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "and binpath NOT LIKE 'TOTAL_%' " \
+ "group by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming " \
- "order by time_stamp, iftype, ifname, imsi, hw_net_protocol_type, " \
+ "order by time_stamp, iftype, ifname, subscriber_id, hw_net_protocol_type, " \
"is_roaming"
#define SELECT_CHUNKS_TOTAL_IFACE "select iftype, hw_net_protocol_type, " \
"is_roaming, sum(received) as received, sum(sent) as sent, " \
- "ifname, imsi, ground, time_stamp - time_stamp % ? as time_stamp " \
+ "ifname, subscriber_id, ground, time_stamp - time_stamp % ? as time_stamp " \
"from statistics where time_stamp between ? and ? " \
"and iftype = ? " \
- "group by time_stamp, hw_net_protocol_type, is_roaming, iftype, ifname, imsi " \
+ "and binpath NOT LIKE 'TOTAL_%' " \
+ "group by time_stamp, hw_net_protocol_type, is_roaming, iftype, ifname, subscriber_id " \
"order by time_stamp, hw_net_protocol_type, is_roaming, iftype, " \
- "ifname, imsi"
+ "ifname, subscriber_id"
/* INSERT statement */
#define INSERT_VALUES "insert into statistics " \
"(binpath, received, sent, time_stamp, " \
"iftype, is_roaming, hw_net_protocol_type, " \
- "ifname, imsi, ground) " \
+ "ifname, subscriber_id, ground) " \
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
static void __finalize_delete(void);
static int initialized;
if (initialized) {
- __STC_LOG_FUNC_EXIT__;
- return SQLITE_OK;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return SQLITE_OK; //LCOV_EXCL_LINE
}
PREPARE_DELETE(delete_query[0], DELETE_ALL);
static int initialized;
if (initialized) {
- __STC_LOG_FUNC_EXIT__;
- return SQLITE_OK;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return SQLITE_OK; //LCOV_EXCL_LINE
}
PREPARE_SELECT(select_for_period, SELECT_FOR_PERIOD);
static int initialized;
if (initialized) {
- __STC_LOG_FUNC_EXIT__;
- return SQLITE_OK;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return SQLITE_OK; //LCOV_EXCL_LINE
}
PREPARE_INSERT(update_statistics_query, INSERT_VALUES);
return *details_stms[stm_index];
}
+//LCOV_EXCL_START
stc_error_e table_statistics_reset_first_n_entries(int num)
{
__STC_LOG_FUNC_ENTER__;
sqlite3_reset(delete_query[4]);
return error_code;
}
+//LCOV_EXCL_STOP
stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule)
{
__STC_LOG_FUNC_ENTER__;
sqlite3_stmt *stmt;
stc_error_e error_code = STC_ERROR_NONE;
- int pos = 1;/* running through positions where to
+ int pos = 1; /* running through positions where to
bind parameters in the query */
if (!rule || !rule->interval) {
- __STC_LOG_FUNC_EXIT__;
- return STC_ERROR_INVALID_PARAMETER;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
/* pick a statement depending on parameters.
DB_ACTION(sqlite3_bind_int64(stmt, pos++, rule->interval->to));
if (sqlite3_step(stmt) != SQLITE_DONE) {
- STC_LOGE("Failed to drop collected statistics.");
- error_code = STC_ERROR_DB_FAILED;
- __STC_LOG_FUNC_EXIT__;
- goto handle_error;
+ STC_LOGE("Failed to drop collected statistics."); //LCOV_EXCL_LINE
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ goto handle_error; //LCOV_EXCL_LINE
}
STC_LOGD("Entry deleted successfully.");
memset(&data, 0, sizeof(data));
if (!rule || !info_cb) {
- __STC_LOG_FUNC_EXIT__;
- return STC_ERROR_INVALID_PARAMETER;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
/* pick a statement depending on parameters */
data.roaming = sqlite3_column_int(stmt, 2);
data.cnt.in_bytes = sqlite3_column_int64(stmt, 3);
data.cnt.out_bytes = sqlite3_column_int64(stmt, 4);
- data.imsi = (char *)sqlite3_column_text(stmt, 5);
+ data.subscriber_id = (char *)sqlite3_column_text(stmt, 5);
data.ground = sqlite3_column_int(stmt, 6);
data.iftype = sqlite3_column_int(stmt, 7);
data.ifname = (char *)sqlite3_column_text(stmt, 8);
}
if (info_cb(&data, user_data) == STC_CANCEL)
- rc = SQLITE_DONE;/* emulate end of data */
+ rc = SQLITE_DONE; //LCOV_EXCL_LINE
__STC_LOG_FUNC_EXIT__;
break;
case SQLITE_DONE:
break;
case SQLITE_ERROR:
default:
- error_code = STC_ERROR_DB_FAILED;
- __STC_LOG_FUNC_EXIT__;
- break;
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ break; //LCOV_EXCL_LINE
}
} while (rc == SQLITE_ROW);
sqlite3_stmt *stmt;
stc_error_e error_code = STC_ERROR_NONE;
int rc;
- int pos = 1;/* running through positions
+ int pos = 1; /* running through positions
where to bind parameters in the query */
stc_db_tm_interval_s interval;
memset(&data, 0, sizeof(data));
if (!rule || !info_cb) {
- __STC_LOG_FUNC_EXIT__;
- return STC_ERROR_INVALID_PARAMETER;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
/* pick a statement depending on parameters.
data.cnt.in_bytes = sqlite3_column_int64(stmt, 3);
data.cnt.out_bytes = sqlite3_column_int64(stmt, 4);
data.ifname = (char *)sqlite3_column_text(stmt, 5);
- data.imsi = (char *)sqlite3_column_text(stmt, 6);
+ data.subscriber_id = (char *)sqlite3_column_text(stmt, 6);
data.ground = sqlite3_column_int(stmt, 7);
if (rule->granularity) {
}
if (info_cb(&data, user_data) == STC_CANCEL)
- rc = SQLITE_DONE; /* emulate end of data */
+ rc = SQLITE_DONE; //LCOV_EXCL_LINE
__STC_LOG_FUNC_EXIT__;
break;
case SQLITE_DONE:
break;
case SQLITE_ERROR:
default:
- error_code = STC_ERROR_DB_FAILED;
- __STC_LOG_FUNC_EXIT__;
- break;
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ break; //LCOV_EXCL_LINE
}
} while (rc == SQLITE_ROW);
{
stc_error_e error_code = STC_ERROR_NONE;
sqlite3_stmt *stmt = update_statistics_query;
- stc_hw_net_protocol_type_e hw_net_protocol_type = STC_PROTOCOL_NONE;
+ stc_hw_net_protocol_type_e hw_net_protocol_type = STC_PROTOCOL_UNKNOWN;
if (!stat->rcv_count && !stat->snd_count) {
error_code = STC_ERROR_INVALID_PARAMETER;
SQLITE_STATIC));
DB_ACTION(sqlite3_bind_int(stmt, 2, stat->rcv_count));
DB_ACTION(sqlite3_bind_int(stmt, 3, stat->snd_count));
- DB_ACTION(sqlite3_bind_int64(stmt, 4,
- (sqlite3_int64)(last_touch_time)));
+ DB_ACTION(sqlite3_bind_int64(stmt, 4, (sqlite3_int64)last_touch_time));
DB_ACTION(sqlite3_bind_int(stmt, 5, (int)(stat_key->iftype)));
DB_ACTION(sqlite3_bind_int(stmt, 6, (int)(stat->is_roaming)));
DB_ACTION(sqlite3_bind_int(stmt, 7, (int)hw_net_protocol_type));
DB_ACTION(sqlite3_bind_text(stmt, 8, stat_key->ifname, -1,
SQLITE_STATIC));
DB_ACTION(sqlite3_bind_text(stmt, 9,
- stat_key->imsi ? stat_key->imsi : "" , -1,
+ stat_key->subscriber_id ? stat_key->subscriber_id : "" , -1,
SQLITE_STATIC));
DB_ACTION(sqlite3_bind_int(stmt, 10, (int)stat->ground));
stat->rcv_count = 0;
stat->snd_count = 0;
if (sqlite3_step(stmt) != SQLITE_DONE) {
- STC_LOGE("Failed to record appstat. %s",
+ STC_LOGE("Failed to record appstat. %s", //LCOV_EXCL_LINE
sqlite3_errmsg(stc_db_get_database()));
- error_code = STC_ERROR_DB_FAILED;
- __STC_LOG_FUNC_EXIT__;
- goto handle_error;
+ error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ goto handle_error; //LCOV_EXCL_LINE
}
- STC_LOGD("App stat recorded [%s]", stat->app_id);
+ if (STC_DEBUG_LOG)
+ STC_LOGD("App stat recorded [%s]", stat->app_id);
handle_error:
sqlite3_reset(stmt);
stc_error_e error_code = STC_ERROR_NONE;
if (db == NULL) {
- __STC_LOG_FUNC_EXIT__;
- return STC_ERROR_DB_FAILED;
+ __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+ return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
}
DB_ACTION(__prepare_delete(db));