| 3102 | } |
| 3103 | |
| 3104 | int cbm_store_coverage_meta_get(cbm_store_t *s, const char *project, cbm_coverage_meta_t *out) { |
| 3105 | if (!out) { |
| 3106 | return CBM_STORE_ERR; |
| 3107 | } |
| 3108 | memset(out, 0, sizeof(*out)); |
| 3109 | if (!s || !s->db || !project) { |
| 3110 | return CBM_STORE_ERR; |
| 3111 | } |
| 3112 | sqlite3_stmt *stmt = NULL; |
| 3113 | if (sqlite3_prepare_v2(s->db, |
| 3114 | "SELECT project, generation, index_mode, recorded_at, recording_status, " |
| 3115 | "ignored_files_stored, ignored_files_total, coverage_version, " |
| 3116 | "hash_records_complete FROM index_coverage_meta WHERE project = ?1;", |
| 3117 | CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) { |
| 3118 | store_set_error_sqlite(s, "coverage meta get prepare"); |
| 3119 | return CBM_STORE_ERR; |
| 3120 | } |
| 3121 | bind_text(stmt, SKIP_ONE, project); |
| 3122 | int rc = sqlite3_step(stmt); |
| 3123 | if (rc == SQLITE_ROW) { |
| 3124 | out->project = heap_strdup((const char *)sqlite3_column_text(stmt, 0)); |
| 3125 | out->generation = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE)); |
| 3126 | out->index_mode = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_2)); |
| 3127 | out->recorded_at = heap_strdup((const char *)sqlite3_column_text(stmt, ST_COL_3)); |
| 3128 | out->recording_status = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_4)); |
| 3129 | out->ignored_files_stored = sqlite3_column_int(stmt, CBM_SZ_5); |
| 3130 | out->ignored_files_total = sqlite3_column_int(stmt, 6); |
| 3131 | out->coverage_version = sqlite3_column_int(stmt, 7); |
| 3132 | out->hash_records_complete = sqlite3_column_int(stmt, 8) != 0; |
| 3133 | sqlite3_finalize(stmt); |
| 3134 | if (!out->project || !out->generation || !out->index_mode || !out->recorded_at || |
| 3135 | !out->recording_status) { |
| 3136 | cbm_store_coverage_meta_clear(out); |
| 3137 | return CBM_STORE_ERR; |
| 3138 | } |
| 3139 | return CBM_STORE_OK; |
| 3140 | } |
| 3141 | sqlite3_finalize(stmt); |
| 3142 | if (rc != SQLITE_DONE) { |
| 3143 | store_set_error_sqlite(s, "coverage meta get"); |
| 3144 | return CBM_STORE_ERR; |
| 3145 | } |
| 3146 | return CBM_STORE_NOT_FOUND; |
| 3147 | } |
| 3148 | |
| 3149 | int cbm_store_coverage_get(cbm_store_t *s, const char *project, cbm_coverage_row_t **out, |
| 3150 | int *count) { |
no test coverage detected