Skip to content

Commit

Permalink
MSEARCH-794: fix status setting query
Browse files Browse the repository at this point in the history
  • Loading branch information
mukhiddin-yusuf committed Aug 16, 2024
1 parent 55945b9 commit 55e19af
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.folio.search.service.reindex.jdbc;

import static org.folio.search.model.reindex.ReindexStatusEntity.END_TIME_MERGE_COLUMN;
import static org.folio.search.model.reindex.ReindexStatusEntity.END_TIME_UPLOAD_COLUMN;
import static org.folio.search.model.reindex.ReindexStatusEntity.START_TIME_MERGE_COLUMN;
import static org.folio.search.model.reindex.ReindexStatusEntity.STATUS_COLUMN;
import static org.folio.search.model.reindex.ReindexStatusEntity.TOTAL_MERGE_RANGES_COLUMN;
Expand Down Expand Up @@ -60,20 +59,13 @@ public void setMergeReindexStarted(ReindexEntityType entityType, int totalMergeR
jdbcTemplate.update(sql, totalMergeRanges, Timestamp.from(Instant.now()), entityType.name());
}

public void setReindexUploadFailed(ReindexEntityType entityType) {
var fullTableName = getFullTableName(context, REINDEX_STATUS_TABLE);
var sql = UPDATE_SQL.formatted(fullTableName, "%s = ?".formatted(END_TIME_UPLOAD_COLUMN));

jdbcTemplate.update(sql, ReindexStatus.UPLOAD_FAILED.name(), Timestamp.from(Instant.now()), entityType.name());
}

public void setReindexMergeFailed(List<ReindexEntityType> entityTypes) {
var inTypes = entityTypes.stream()
.map(entityType -> "'%s'".formatted(entityType.name()))
.collect(Collectors.joining(","));
var fullTableName = getFullTableName(context, REINDEX_STATUS_TABLE);
var sql = UPDATE_FOR_ENTITIES_SQL.formatted(
fullTableName, "%s = ?, %s = ?".formatted(STATUS_COLUMN, END_TIME_MERGE_COLUMN));
fullTableName, "%s = '?', %s = ?".formatted(STATUS_COLUMN, END_TIME_MERGE_COLUMN));

log.info("inTypes: {}", inTypes);
log.info("sql: {}", sql);
Expand Down

0 comments on commit 55e19af

Please sign in to comment.