+stc_error_e table_counters_get_timestamps(uint64_t restriction_id,
+ table_counters_info *info)
+{
+ stc_error_e error_code = STC_ERROR_NONE;
+ sqlite3_stmt *stmt = select_timestamp;
+ int rc;
+
+ if (info == NULL) {
+ __STC_LOG_FUNC_EXIT__;
+ goto handle_error;
+ }
+
+ info->restriction_id = restriction_id;
+
+ DB_ACTION(sqlite3_bind_int64(stmt, 1, restriction_id));
+
+ do {
+ rc = sqlite3_step(stmt);
+
+ //LCOV_EXCL_START
+ switch (rc) {
+ case SQLITE_DONE:
+ break;
+ case SQLITE_ROW:
+ info->month_start_date = sqlite3_column_int(stmt, 0);
+ info->month_start_ts = sqlite3_column_int64(stmt, 1);
+ info->week_start_ts = sqlite3_column_int64(stmt, 2);
+ info->day_start_ts = sqlite3_column_int64(stmt, 3);
+
+ STC_LOGD("rstn_id [%llu] month_start_date [%d], "
+ "month_start_ts [%lld], week_start_ts [%lld], "
+ "day_start_ts [%lld]", restriction_id,
+ info->month_start_date, info->month_start_ts,
+ info->week_start_ts, info->day_start_ts);
+ break;
+ case SQLITE_ERROR:
+ default:
+ STC_LOGE("Failed to enumerate counters: %s\n",
+ sqlite3_errmsg(stc_db_get_database()));
+
+ error_code = STC_ERROR_DB_FAILED;
+ __STC_LOG_FUNC_EXIT__;
+ }
+ //LCOV_EXCL_STOP
+ } while (rc == SQLITE_ROW);
+
+handle_error:
+ sqlite3_reset(stmt);
+ return error_code;
+}
+
+//LCOV_EXCL_START
+stc_error_e table_counters_update_timestamps(const table_counters_info *info)
+{
+ stc_error_e error_code = STC_ERROR_NONE;
+ sqlite3_stmt *stmt = update_timestamp;
+
+ if (__table_counters_is_entry_present(info->restriction_id) == FALSE)
+ stmt = insert_timestamp;
+
+ DB_ACTION(sqlite3_bind_int64(stmt, 1, info->restriction_id));
+ DB_ACTION(sqlite3_bind_int(stmt, 2, info->month_start_date));
+ DB_ACTION(sqlite3_bind_int64(stmt, 3, info->month_start_ts));
+ DB_ACTION(sqlite3_bind_int64(stmt, 4, info->week_start_ts));
+ DB_ACTION(sqlite3_bind_int64(stmt, 5, info->day_start_ts));
+
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ STC_LOGE("Failed to update timestamps: %s\n",
+ sqlite3_errmsg(stc_db_get_database()));
+ error_code = STC_ERROR_DB_FAILED;
+ __STC_LOG_FUNC_EXIT__;
+ goto handle_error;
+ }
+
+ STC_LOGD("Timestamps updated for restriction_id [%llu]",
+ info->restriction_id);
+
+handle_error:
+ sqlite3_reset(stmt);
+ return error_code;
+}
+//LCOV_EXCL_STOP
+
+