| 3195 | } |
| 3196 | |
| 3197 | int cbm_store_coverage_meta_get(cbm_store_t *s, const char *project, cbm_coverage_meta_t *out) { |
| 3198 | if (!out) { |
| 3199 | return CBM_STORE_ERR; |
| 3200 | } |
| 3201 | memset(out, 0, sizeof(*out)); |
| 3202 | if (!s || !s->db || !project) { |
| 3203 | return CBM_STORE_ERR; |
| 3204 | } |
| 3205 | sqlite3_stmt *stmt = NULL; |
| 3206 | if (sqlite3_prepare_v2(s->db, |
| 3207 | "SELECT project, generation, index_mode, recorded_at, recording_status, " |
| 3208 | "ignored_files_stored, ignored_files_total, coverage_version, " |
| 3209 | "hash_records_complete FROM index_coverage_meta WHERE project = ?1;", |
| 3210 | CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) { |
| 3211 | store_set_error_sqlite(s, "coverage meta get prepare"); |
| 3212 | return CBM_STORE_ERR; |
| 3213 | } |
| 3214 | bind_text(stmt, SKIP_ONE, project); |
| 3215 | int rc = sqlite3_step(stmt); |
| 3216 | if (rc == SQLITE_ROW) { |
| 3217 | out->project = heap_strdup((const char *)sqlite3_column_text(stmt, 0)); |
| 3218 | out->generation = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE)); |
| 3219 | out->index_mode = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_2)); |
| 3220 | out->recorded_at = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_3)); |
| 3221 | out->recording_status = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_4)); |
| 3222 | out->ignored_files_stored = sqlite3_column_int(stmt, CBM_SZ_5); |
| 3223 | out->ignored_files_total = sqlite3_column_int(stmt, 6); |
| 3224 | out->coverage_version = sqlite3_column_int(stmt, 7); |
| 3225 | out->hash_records_complete = sqlite3_column_int(stmt, 8) != 0; |
| 3226 | sqlite3_finalize(stmt); |
| 3227 | if (!out->project || !out->generation || !out->index_mode || !out->recorded_at || |
| 3228 | !out->recording_status) { |
| 3229 | cbm_store_coverage_meta_clear(out); |
| 3230 | return CBM_STORE_ERR; |
| 3231 | } |
| 3232 | return CBM_STORE_OK; |
| 3233 | } |
| 3234 | sqlite3_finalize(stmt); |
| 3235 | if (rc != SQLITE_DONE) { |
| 3236 | store_set_error_sqlite(s, "coverage meta get"); |
| 3237 | return CBM_STORE_ERR; |
| 3238 | } |
| 3239 | return CBM_STORE_NOT_FOUND; |
| 3240 | } |
| 3241 | |
| 3242 | int cbm_store_coverage_get(cbm_store_t *s, const char *project, cbm_coverage_row_t **out, |
| 3243 | int *count) { |
no test coverage detected