| 3001 | } |
| 3002 | |
| 3003 | int cbm_store_coverage_meta_get(cbm_store_t *s, const char *project, cbm_coverage_meta_t *out) { |
| 3004 | if (!out) { |
| 3005 | return CBM_STORE_ERR; |
| 3006 | } |
| 3007 | memset(out, 0, sizeof(*out)); |
| 3008 | if (!s || !s->db || !project) { |
| 3009 | return CBM_STORE_ERR; |
| 3010 | } |
| 3011 | sqlite3_stmt *stmt = NULL; |
| 3012 | if (sqlite3_prepare_v2(s->db, |
| 3013 | "SELECT project, generation, index_mode, recorded_at, recording_status, " |
| 3014 | "ignored_files_stored, ignored_files_total, coverage_version, " |
| 3015 | "hash_records_complete FROM index_coverage_meta WHERE project = ?1;", |
| 3016 | CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) { |
| 3017 | store_set_error_sqlite(s, "coverage meta get prepare"); |
| 3018 | return CBM_STORE_ERR; |
| 3019 | } |
| 3020 | bind_text(stmt, SKIP_ONE, project); |
| 3021 | int rc = sqlite3_step(stmt); |
| 3022 | if (rc == SQLITE_ROW) { |
| 3023 | out->project = heap_strdup((const char *)sqlite3_column_text(stmt, 0)); |
| 3024 | out->generation = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE)); |
| 3025 | out->index_mode = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_2)); |
| 3026 | out->recorded_at = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_3)); |
| 3027 | out->recording_status = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_4)); |
| 3028 | out->ignored_files_stored = sqlite3_column_int(stmt, CBM_SZ_5); |
| 3029 | out->ignored_files_total = sqlite3_column_int(stmt, 6); |
| 3030 | out->coverage_version = sqlite3_column_int(stmt, 7); |
| 3031 | out->hash_records_complete = sqlite3_column_int(stmt, 8) != 0; |
| 3032 | sqlite3_finalize(stmt); |
| 3033 | if (!out->project || !out->generation || !out->index_mode || !out->recorded_at || |
| 3034 | !out->recording_status) { |
| 3035 | cbm_store_coverage_meta_clear(out); |
| 3036 | return CBM_STORE_ERR; |
| 3037 | } |
| 3038 | return CBM_STORE_OK; |
| 3039 | } |
| 3040 | sqlite3_finalize(stmt); |
| 3041 | if (rc != SQLITE_DONE) { |
| 3042 | store_set_error_sqlite(s, "coverage meta get"); |
| 3043 | return CBM_STORE_ERR; |
| 3044 | } |
| 3045 | return CBM_STORE_NOT_FOUND; |
| 3046 | } |
| 3047 | |
| 3048 | int cbm_store_coverage_get(cbm_store_t *s, const char *project, cbm_coverage_row_t **out, |
| 3049 | int *count) { |
no test coverage detected