mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-22 02:02:14 +00:00
fix batch status display
This commit is contained in:
parent
b5853b0de6
commit
32c9f836e5
@ -443,7 +443,6 @@ class BatchChangeService(
|
|||||||
changes,
|
changes,
|
||||||
batchChangeInput.ownerGroupId,
|
batchChangeInput.ownerGroupId,
|
||||||
BatchChangeApprovalStatus.PendingReview,
|
BatchChangeApprovalStatus.PendingReview,
|
||||||
BatchChangeStatus.PendingReview,
|
|
||||||
scheduledTime = batchChangeInput.scheduledTime
|
scheduledTime = batchChangeInput.scheduledTime
|
||||||
).asRight
|
).asRight
|
||||||
}
|
}
|
||||||
@ -459,7 +458,6 @@ class BatchChangeService(
|
|||||||
changes,
|
changes,
|
||||||
batchChangeInput.ownerGroupId,
|
batchChangeInput.ownerGroupId,
|
||||||
BatchChangeApprovalStatus.AutoApproved,
|
BatchChangeApprovalStatus.AutoApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
scheduledTime = batchChangeInput.scheduledTime
|
scheduledTime = batchChangeInput.scheduledTime
|
||||||
).asRight
|
).asRight
|
||||||
}
|
}
|
||||||
|
@ -1041,7 +1041,6 @@ class BatchChangeServiceSpec
|
|||||||
List(),
|
List(),
|
||||||
ownerGroupId = Some(okGroup.id),
|
ownerGroupId = Some(okGroup.id),
|
||||||
BatchChangeApprovalStatus.ManuallyApproved,
|
BatchChangeApprovalStatus.ManuallyApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
Some(superUser.id),
|
Some(superUser.id),
|
||||||
None,
|
None,
|
||||||
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS))
|
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS))
|
||||||
@ -2549,7 +2548,6 @@ class BatchChangeServiceSpec
|
|||||||
Instant.now.truncatedTo(ChronoUnit.MILLIS),
|
Instant.now.truncatedTo(ChronoUnit.MILLIS),
|
||||||
List(),
|
List(),
|
||||||
approvalStatus = BatchChangeApprovalStatus.PendingReview,
|
approvalStatus = BatchChangeApprovalStatus.PendingReview,
|
||||||
batchStatus = BatchChangeStatus.PendingReview
|
|
||||||
)
|
)
|
||||||
batchChangeRepo.save(batchChangeOne)
|
batchChangeRepo.save(batchChangeOne)
|
||||||
|
|
||||||
@ -2560,7 +2558,6 @@ class BatchChangeServiceSpec
|
|||||||
Instant.ofEpochMilli(Instant.now.truncatedTo(ChronoUnit.MILLIS).toEpochMilli + 1000),
|
Instant.ofEpochMilli(Instant.now.truncatedTo(ChronoUnit.MILLIS).toEpochMilli + 1000),
|
||||||
List(),
|
List(),
|
||||||
approvalStatus = BatchChangeApprovalStatus.AutoApproved,
|
approvalStatus = BatchChangeApprovalStatus.AutoApproved,
|
||||||
batchStatus = BatchChangeStatus.PendingProcessing
|
|
||||||
)
|
)
|
||||||
batchChangeRepo.save(batchChangeTwo)
|
batchChangeRepo.save(batchChangeTwo)
|
||||||
|
|
||||||
@ -2578,8 +2575,7 @@ class BatchChangeServiceSpec
|
|||||||
result.ignoreAccess shouldBe false
|
result.ignoreAccess shouldBe false
|
||||||
result.batchStatus shouldBe Some(BatchChangeStatus.PendingReview)
|
result.batchStatus shouldBe Some(BatchChangeStatus.PendingReview)
|
||||||
|
|
||||||
result.batchChanges.length shouldBe 1
|
result.batchChanges.length shouldBe 2
|
||||||
result.batchChanges(0).status shouldBe batchChangeOne.batchStatus
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2719,7 +2715,6 @@ class BatchChangeServiceSpec
|
|||||||
List(singleChangeGood, singleChangeNR),
|
List(singleChangeGood, singleChangeNR),
|
||||||
Some(authGrp.id),
|
Some(authGrp.id),
|
||||||
BatchChangeApprovalStatus.ManuallyApproved,
|
BatchChangeApprovalStatus.ManuallyApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
Some("reviewer_id"),
|
Some("reviewer_id"),
|
||||||
Some("approved"),
|
Some("approved"),
|
||||||
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS))
|
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS))
|
||||||
|
@ -100,7 +100,6 @@ class EmailNotifierSpec
|
|||||||
changes,
|
changes,
|
||||||
None,
|
None,
|
||||||
BatchChangeApprovalStatus.AutoApproved,
|
BatchChangeApprovalStatus.AutoApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -27,7 +27,7 @@ import org.mockito.Matchers._
|
|||||||
import org.mockito.Mockito._
|
import org.mockito.Mockito._
|
||||||
import org.mockito.ArgumentCaptor
|
import org.mockito.ArgumentCaptor
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
import _root_.vinyldns.core.domain.batch.{BatchChange, BatchChangeApprovalStatus, BatchChangeStatus, SingleAddChange, SingleChange, SingleChangeStatus, SingleDeleteRRSetChange}
|
import _root_.vinyldns.core.domain.batch.{BatchChange, BatchChangeApprovalStatus, SingleAddChange, SingleChange, SingleChangeStatus, SingleDeleteRRSetChange}
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import vinyldns.core.domain.record.RecordType
|
import vinyldns.core.domain.record.RecordType
|
||||||
import vinyldns.core.domain.record.AData
|
import vinyldns.core.domain.record.AData
|
||||||
@ -65,7 +65,6 @@ class SnsNotifierSpec
|
|||||||
changes,
|
changes,
|
||||||
None,
|
None,
|
||||||
BatchChangeApprovalStatus.AutoApproved,
|
BatchChangeApprovalStatus.AutoApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -39,7 +39,6 @@ class InMemoryBatchChangeRepository extends BatchChangeRepository {
|
|||||||
ownerGroupId: Option[String],
|
ownerGroupId: Option[String],
|
||||||
id: String,
|
id: String,
|
||||||
approvalStatus: BatchChangeApprovalStatus,
|
approvalStatus: BatchChangeApprovalStatus,
|
||||||
batchStatus: BatchChangeStatus,
|
|
||||||
reviewerId: Option[String],
|
reviewerId: Option[String],
|
||||||
reviewComment: Option[String],
|
reviewComment: Option[String],
|
||||||
reviewTimestamp: Option[Instant]
|
reviewTimestamp: Option[Instant]
|
||||||
@ -55,7 +54,6 @@ class InMemoryBatchChangeRepository extends BatchChangeRepository {
|
|||||||
batchChange.ownerGroupId,
|
batchChange.ownerGroupId,
|
||||||
batchChange.id,
|
batchChange.id,
|
||||||
batchChange.approvalStatus,
|
batchChange.approvalStatus,
|
||||||
batchChange.batchStatus,
|
|
||||||
batchChange.reviewerId,
|
batchChange.reviewerId,
|
||||||
batchChange.reviewComment,
|
batchChange.reviewComment,
|
||||||
batchChange.reviewTimestamp
|
batchChange.reviewTimestamp
|
||||||
@ -90,7 +88,6 @@ class InMemoryBatchChangeRepository extends BatchChangeRepository {
|
|||||||
singleChangesFromRepo,
|
singleChangesFromRepo,
|
||||||
sc.ownerGroupId,
|
sc.ownerGroupId,
|
||||||
sc.approvalStatus,
|
sc.approvalStatus,
|
||||||
sc.batchStatus,
|
|
||||||
sc.reviewerId,
|
sc.reviewerId,
|
||||||
sc.reviewComment,
|
sc.reviewComment,
|
||||||
sc.reviewTimestamp,
|
sc.reviewTimestamp,
|
||||||
@ -135,7 +132,6 @@ class InMemoryBatchChangeRepository extends BatchChangeRepository {
|
|||||||
|
|
||||||
val userBatchChanges = batches.values.toList
|
val userBatchChanges = batches.values.toList
|
||||||
.filter(b => userId.forall(_ == b.userId))
|
.filter(b => userId.forall(_ == b.userId))
|
||||||
.filter(bs => batchStatus.forall(_ == bs.batchStatus))
|
|
||||||
.filter(bu => userName.forall(_ == bu.userName))
|
.filter(bu => userName.forall(_ == bu.userName))
|
||||||
.filter(bdtsi => startInstant.forall(_.isBefore(bdtsi.createdTimestamp)))
|
.filter(bdtsi => startInstant.forall(_.isBefore(bdtsi.createdTimestamp)))
|
||||||
.filter(bdtei => endInstant.forall(_.isAfter(bdtei.createdTimestamp)))
|
.filter(bdtei => endInstant.forall(_.isAfter(bdtei.createdTimestamp)))
|
||||||
@ -152,7 +148,6 @@ class InMemoryBatchChangeRepository extends BatchChangeRepository {
|
|||||||
changes,
|
changes,
|
||||||
sc.ownerGroupId,
|
sc.ownerGroupId,
|
||||||
sc.approvalStatus,
|
sc.approvalStatus,
|
||||||
sc.batchStatus,
|
|
||||||
sc.reviewerId,
|
sc.reviewerId,
|
||||||
sc.reviewComment,
|
sc.reviewComment,
|
||||||
sc.reviewTimestamp,
|
sc.reviewTimestamp,
|
||||||
|
@ -482,7 +482,6 @@ class BatchChangeJsonProtocolSpec
|
|||||||
List(add, delete),
|
List(add, delete),
|
||||||
None,
|
None,
|
||||||
BatchChangeApprovalStatus.PendingReview,
|
BatchChangeApprovalStatus.PendingReview,
|
||||||
BatchChangeStatus.PendingReview,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -617,7 +616,6 @@ class BatchChangeJsonProtocolSpec
|
|||||||
List(add, delete),
|
List(add, delete),
|
||||||
None,
|
None,
|
||||||
BatchChangeApprovalStatus.PendingReview,
|
BatchChangeApprovalStatus.PendingReview,
|
||||||
BatchChangeStatus.PendingReview,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -133,7 +133,6 @@ class BatchChangeRoutingSpec()
|
|||||||
),
|
),
|
||||||
ownerGroupId,
|
ownerGroupId,
|
||||||
approvalStatus,
|
approvalStatus,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -31,7 +31,6 @@ case class BatchChange(
|
|||||||
changes: List[SingleChange],
|
changes: List[SingleChange],
|
||||||
ownerGroupId: Option[String] = None,
|
ownerGroupId: Option[String] = None,
|
||||||
approvalStatus: BatchChangeApprovalStatus,
|
approvalStatus: BatchChangeApprovalStatus,
|
||||||
batchStatus: BatchChangeStatus = BatchChangeStatus.PendingProcessing,
|
|
||||||
reviewerId: Option[String] = None,
|
reviewerId: Option[String] = None,
|
||||||
reviewComment: Option[String] = None,
|
reviewComment: Option[String] = None,
|
||||||
reviewTimestamp: Option[Instant] = None,
|
reviewTimestamp: Option[Instant] = None,
|
||||||
|
@ -47,7 +47,6 @@ class BatchChangeSummarySpec extends AnyWordSpec with Matchers {
|
|||||||
List(pendingChange, failedChange, completeChange),
|
List(pendingChange, failedChange, completeChange),
|
||||||
Some("groupId"),
|
Some("groupId"),
|
||||||
BatchChangeApprovalStatus.AutoApproved,
|
BatchChangeApprovalStatus.AutoApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -33,7 +33,7 @@ import vinyldns.core.domain.{SingleChangeError, ZoneDiscoveryError}
|
|||||||
import vinyldns.mysql.TestMySqlInstance
|
import vinyldns.mysql.TestMySqlInstance
|
||||||
|
|
||||||
class MySqlBatchChangeRepositoryIntegrationSpec
|
class MySqlBatchChangeRepositoryIntegrationSpec
|
||||||
extends AnyWordSpec
|
extends AnyWordSpec
|
||||||
with BeforeAndAfterAll
|
with BeforeAndAfterAll
|
||||||
with BeforeAndAfterEach
|
with BeforeAndAfterEach
|
||||||
with Matchers
|
with Matchers
|
||||||
@ -47,11 +47,11 @@ class MySqlBatchChangeRepositoryIntegrationSpec
|
|||||||
|
|
||||||
object TestData {
|
object TestData {
|
||||||
def generateSingleAddChange(
|
def generateSingleAddChange(
|
||||||
recordType: RecordType,
|
recordType: RecordType,
|
||||||
recordData: RecordData,
|
recordData: RecordData,
|
||||||
status: SingleChangeStatus = Pending,
|
status: SingleChangeStatus = Pending,
|
||||||
errors: List[SingleChangeError] = List.empty
|
errors: List[SingleChangeError] = List.empty
|
||||||
): SingleAddChange =
|
): SingleAddChange =
|
||||||
SingleAddChange(
|
SingleAddChange(
|
||||||
Some(okZone.id),
|
Some(okZone.id),
|
||||||
Some(okZone.name),
|
Some(okZone.name),
|
||||||
@ -103,7 +103,6 @@ class MySqlBatchChangeRepositoryIntegrationSpec
|
|||||||
changes,
|
changes,
|
||||||
Some(UUID.randomUUID().toString),
|
Some(UUID.randomUUID().toString),
|
||||||
BatchChangeApprovalStatus.AutoApproved,
|
BatchChangeApprovalStatus.AutoApproved,
|
||||||
BatchChangeStatus.PendingProcessing,
|
|
||||||
Some(UUID.randomUUID().toString),
|
Some(UUID.randomUUID().toString),
|
||||||
Some("review comment"),
|
Some("review comment"),
|
||||||
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS).plusSeconds(2))
|
Some(Instant.now.truncatedTo(ChronoUnit.MILLIS).plusSeconds(2))
|
||||||
@ -456,8 +455,7 @@ class MySqlBatchChangeRepositoryIntegrationSpec
|
|||||||
} yield (updated, saved)
|
} yield (updated, saved)
|
||||||
|
|
||||||
val (retrieved, saved) = f.unsafeRunSync
|
val (retrieved, saved) = f.unsafeRunSync
|
||||||
// Batch Change Status will be updated once saved
|
retrieved shouldBe saved
|
||||||
retrieved.map(x => x.copy(batchStatus = BatchChangeStatus.Complete)) shouldBe saved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"return no batch when single changes list is empty" in {
|
"return no batch when single changes list is empty" in {
|
||||||
|
@ -297,7 +297,6 @@ class MySqlBatchChangeRepository
|
|||||||
val complete = res.int("complete_count")
|
val complete = res.int("complete_count")
|
||||||
val cancelled = res.int("cancelled_count")
|
val cancelled = res.int("cancelled_count")
|
||||||
val approvalStatus = toApprovalStatus(res.intOpt("approval_status"))
|
val approvalStatus = toApprovalStatus(res.intOpt("approval_status"))
|
||||||
val batchChangeStatus = toBatchChangeStatus(res.stringOpt("batch_status"))
|
|
||||||
val schedTime =
|
val schedTime =
|
||||||
res.timestampOpt("scheduled_time").map(st => st.toInstant)
|
res.timestampOpt("scheduled_time").map(st => st.toInstant)
|
||||||
val cancelledTimestamp =
|
val cancelledTimestamp =
|
||||||
@ -308,7 +307,14 @@ class MySqlBatchChangeRepository
|
|||||||
Option(res.string("comments")),
|
Option(res.string("comments")),
|
||||||
res.timestamp("created_time").toInstant,
|
res.timestamp("created_time").toInstant,
|
||||||
pending + failed + complete + cancelled,
|
pending + failed + complete + cancelled,
|
||||||
batchChangeStatus,
|
BatchChangeStatus
|
||||||
|
.calculateBatchStatus(
|
||||||
|
approvalStatus,
|
||||||
|
pending > 0,
|
||||||
|
failed > 0,
|
||||||
|
complete > 0,
|
||||||
|
schedTime.isDefined
|
||||||
|
),
|
||||||
Option(res.string("owner_group_id")),
|
Option(res.string("owner_group_id")),
|
||||||
res.string("id"),
|
res.string("id"),
|
||||||
None,
|
None,
|
||||||
@ -363,7 +369,6 @@ class MySqlBatchChangeRepository
|
|||||||
Nil,
|
Nil,
|
||||||
result.stringOpt("owner_group_id"),
|
result.stringOpt("owner_group_id"),
|
||||||
toApprovalStatus(result.intOpt("approval_status")),
|
toApprovalStatus(result.intOpt("approval_status")),
|
||||||
toBatchChangeStatus(result.stringOpt("batch_status")),
|
|
||||||
result.stringOpt("reviewer_id"),
|
result.stringOpt("reviewer_id"),
|
||||||
result.stringOpt("review_comment"),
|
result.stringOpt("review_comment"),
|
||||||
result.timestampOpt("review_timestamp").map(toDateTime),
|
result.timestampOpt("review_timestamp").map(toDateTime),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user