2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-09-02 23:35:18 +00:00

fix batch status display

This commit is contained in:
Aravindh-Raju
2024-11-15 11:15:09 +05:30
parent b5853b0de6
commit 32c9f836e5
11 changed files with 17 additions and 33 deletions

View File

@@ -33,7 +33,7 @@ import vinyldns.core.domain.{SingleChangeError, ZoneDiscoveryError}
import vinyldns.mysql.TestMySqlInstance
class MySqlBatchChangeRepositoryIntegrationSpec
extends AnyWordSpec
extends AnyWordSpec
with BeforeAndAfterAll
with BeforeAndAfterEach
with Matchers
@@ -47,11 +47,11 @@ class MySqlBatchChangeRepositoryIntegrationSpec
object TestData {
def generateSingleAddChange(
recordType: RecordType,
recordData: RecordData,
status: SingleChangeStatus = Pending,
errors: List[SingleChangeError] = List.empty
): SingleAddChange =
recordType: RecordType,
recordData: RecordData,
status: SingleChangeStatus = Pending,
errors: List[SingleChangeError] = List.empty
): SingleAddChange =
SingleAddChange(
Some(okZone.id),
Some(okZone.name),
@@ -103,7 +103,6 @@ class MySqlBatchChangeRepositoryIntegrationSpec
changes,
Some(UUID.randomUUID().toString),
BatchChangeApprovalStatus.AutoApproved,
BatchChangeStatus.PendingProcessing,
Some(UUID.randomUUID().toString),
Some("review comment"),
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS).plusSeconds(2))
@@ -456,8 +455,7 @@ class MySqlBatchChangeRepositoryIntegrationSpec
} yield (updated, saved)
val (retrieved, saved) = f.unsafeRunSync
// Batch Change Status will be updated once saved
retrieved.map(x => x.copy(batchStatus = BatchChangeStatus.Complete)) shouldBe saved
retrieved shouldBe saved
}
"return no batch when single changes list is empty" in {

View File

@@ -297,7 +297,6 @@ class MySqlBatchChangeRepository
val complete = res.int("complete_count")
val cancelled = res.int("cancelled_count")
val approvalStatus = toApprovalStatus(res.intOpt("approval_status"))
val batchChangeStatus = toBatchChangeStatus(res.stringOpt("batch_status"))
val schedTime =
res.timestampOpt("scheduled_time").map(st => st.toInstant)
val cancelledTimestamp =
@@ -308,7 +307,14 @@ class MySqlBatchChangeRepository
Option(res.string("comments")),
res.timestamp("created_time").toInstant,
pending + failed + complete + cancelled,
batchChangeStatus,
BatchChangeStatus
.calculateBatchStatus(
approvalStatus,
pending > 0,
failed > 0,
complete > 0,
schedTime.isDefined
),
Option(res.string("owner_group_id")),
res.string("id"),
None,
@@ -363,7 +369,6 @@ class MySqlBatchChangeRepository
Nil,
result.stringOpt("owner_group_id"),
toApprovalStatus(result.intOpt("approval_status")),
toBatchChangeStatus(result.stringOpt("batch_status")),
result.stringOpt("reviewer_id"),
result.stringOpt("review_comment"),
result.timestampOpt("review_timestamp").map(toDateTime),