Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drtii 1557 min staff #1947

Merged
merged 117 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
9941f99
initial add min staff component
Aug 27, 2024
4779d05
Merge branch 'master' of github.com:UKHomeOffice/drt-v2 into DRTII-15…
Aug 27, 2024
4cbaeef
Changes to add min staff
Aug 30, 2024
eaee1b7
edit min staff
Aug 30, 2024
e4088f6
state change only min staff
Sep 2, 2024
b67c748
Adding updated version for drt react
Sep 2, 2024
530f6e6
update drt react and add port in montly staffing
Sep 3, 2024
1a26f95
updating updateAt with change in min staff roster
Sep 3, 2024
95ed4b5
merge master
Sep 4, 2024
b3e6a2a
Separating update alert box
Sep 5, 2024
1574037
reposition staff update page
Sep 6, 2024
e2545b6
adding cancel and refresh button
Sep 9, 2024
bc49aa4
DRTII-1557 Min staff end point return updated shifts. Detect update &…
richbirch Sep 10, 2024
9e4e3c0
getting update to work with confirm on monthly staff
Sep 11, 2024
d0a1837
tidy up changes
Sep 11, 2024
7142cd3
fixing unit test
Sep 11, 2024
2381097
merge master
Sep 11, 2024
2403d57
remove commented
Sep 11, 2024
ec8510f
add handler for alert update min staff banner
Sep 12, 2024
e3f3e86
moving ShouldShowMinStaffSuccessBanner to monthly banner
Sep 12, 2024
1c58f70
changing text for min staff
Sep 13, 2024
f2b7948
Drtii 1557 min staff monthly staffing data (#1921)
richbirch Sep 16, 2024
cdff1dc
add Staff Shift form
Sep 20, 2024
69d3aeb
merge master
Sep 23, 2024
bce835d
merge master
Sep 24, 2024
8fc9712
adding json serialisation for api for staff shift api
Sep 24, 2024
581a637
Merge branch 'master' of github.com:UKHomeOffice/drt-v2 into DRTII-15…
Sep 27, 2024
ae44217
Adding staff shift component
Oct 1, 2024
3619743
adding update edit shift
Oct 2, 2024
14256b4
editing staff with drawer
Oct 2, 2024
f277c74
update the edit shift staff
Oct 4, 2024
03534ad
DRTII-1603 Return all shifts on update (#1936)
richbirch Oct 7, 2024
625c78a
Adding dayofWeek
Oct 8, 2024
a683c1e
showing days of week in staff
Oct 8, 2024
9de84aa
adding weekly and daily staff view of planning
ngu04 Oct 10, 2024
5aa8f66
adding weekly controls for staffing
ngu04 Oct 11, 2024
6c6092c
adding previous and next for daily and monthly staff view
ngu04 Oct 11, 2024
e738b73
adding sticky header
ngu04 Oct 11, 2024
afdca41
fixing test
ngu04 Oct 11, 2024
b4ed6d4
fixing timezone
ngu04 Oct 14, 2024
1ea4524
fixing test
ngu04 Oct 14, 2024
c765878
removing min staff number
ngu04 Oct 14, 2024
01fbab3
fixing the column header
ngu04 Oct 14, 2024
5c1d29f
adding feature flag for staffing changes with edit form
ngu04 Oct 15, 2024
87d1a6f
fix FeatureFlagsControllerSpec the test
ngu04 Oct 15, 2024
12641b9
refactor duplicate changes
ngu04 Oct 15, 2024
5d00825
merging master
ngu04 Oct 16, 2024
dd509bf
feature flag for port to enable staffing changes
ngu04 Oct 16, 2024
a9380fb
Update drt-react with date format
ngu04 Oct 17, 2024
d436504
breaking shift 15 mins
ngu04 Oct 21, 2024
d3f24ac
using key for updating
ngu04 Oct 21, 2024
88b08d1
adding shiftUtil for moving override logic
ngu04 Oct 21, 2024
e4d9bf3
Adding test for Split Util
ngu04 Oct 21, 2024
0a92f3b
adding 14 mins interval with 1 min break
ngu04 Oct 21, 2024
a21cac6
fixing test for shiftActor
ngu04 Oct 21, 2024
d8f636c
remove println
ngu04 Oct 22, 2024
89df090
remove sorted
ngu04 Oct 22, 2024
7275d9b
fix test without sort
ngu04 Oct 22, 2024
665776a
update shiftsSequentialWritesActor timeout 90 seconds
ngu04 Oct 22, 2024
cbb6e29
update timeout at drt module
ngu04 Oct 22, 2024
5e10345
adding multiple
ngu04 Oct 22, 2024
052861f
chaning retrievla interval
ngu04 Oct 22, 2024
a9e08e0
removing multiple shifts-actor-writes
ngu04 Oct 22, 2024
23a9ebe
se parallel collections to process
ngu04 Oct 22, 2024
e645007
trying terminal hash
ngu04 Oct 22, 2024
2f36c96
one stop backoff from 30 to 60
ngu04 Oct 23, 2024
0f0c0e0
updating logic for filter terminal check
ngu04 Oct 23, 2024
a8294ba
updating shift sorucecall for understand delay
ngu04 Oct 23, 2024
2fbc607
batch process process recovery for shift actor
ngu04 Oct 23, 2024
3674018
reducing snapshot to 500 for shiftactor
ngu04 Oct 23, 2024
96b2a6f
reducing snapshot to 10 which is temp
ngu04 Oct 24, 2024
6df5b55
Update drt remove async persist call
ngu04 Oct 25, 2024
47fd8a1
updating submode default to an hour for staffing
ngu04 Oct 25, 2024
8c6a49f
few of review comment changes
ngu04 Oct 28, 2024
1fc5333
update logic to update shift
ngu04 Oct 28, 2024
906be86
fixing key for StaffAssignment
ngu04 Oct 28, 2024
e768e0a
few of review comment changes
ngu04 Oct 29, 2024
1c6774b
Adding test for almost 18k shiftsassignment
ngu04 Oct 29, 2024
9138e60
moving consecutive days to util
ngu04 Oct 29, 2024
6105211
fixing weekly and daily staff
ngu04 Oct 29, 2024
e53f585
adding interval base edit form and form style change
ngu04 Oct 30, 2024
1d0e5a1
Drtii 1557 min staff update shifts optimal solution (#1943)
ngu04 Oct 30, 2024
14f7791
adding weekly and daily rolling option in calender
ngu04 Oct 31, 2024
12b4e1e
fixing styling for staffing
ngu04 Nov 1, 2024
d614728
update react component
ngu04 Nov 4, 2024
922dd9f
removing StaffShiftFormService
ngu04 Nov 4, 2024
2931c54
remove PortTerminal Shift reference
ngu04 Nov 4, 2024
e05dbe4
remove temp border added
ngu04 Nov 4, 2024
9bd4e49
making marging left 20 px
ngu04 Nov 4, 2024
2f1840c
update changes
ngu04 Nov 5, 2024
15ae954
review comment changes
ngu04 Nov 5, 2024
29b1099
remove isweekly and isdaily boolean param
ngu04 Nov 5, 2024
b0c7463
rename EditShiftStaffForm to UpdateStaffForTimeRangeForm
ngu04 Nov 5, 2024
735b532
DRTII-1557 Correct test name
richbirch Nov 5, 2024
0ac7712
update setting
ngu04 Nov 5, 2024
36ba7a7
Merge branch 'DRTII-1557-min-staff' of github.com:UKHomeOffice/drt-v2…
ngu04 Nov 5, 2024
88251e6
fixing e2e
ngu04 Nov 5, 2024
13c598e
update prevent to failing test
ngu04 Nov 6, 2024
5ec793d
waiting for saveshift to complete
ngu04 Nov 6, 2024
829a364
temp adding wait
ngu04 Nov 6, 2024
8b2eca4
update react component
ngu04 Nov 6, 2024
5dd62ae
update react version 1.5.4
ngu04 Nov 6, 2024
7214e05
merge master
ngu04 Nov 6, 2024
62a693a
Merge branch 'master' of github.com:UKHomeOffice/drt-v2 into DRTII-15…
ngu04 Nov 6, 2024
73acd16
update package json
ngu04 Nov 6, 2024
885abb0
using commit hash
ngu04 Nov 6, 2024
b000acd
using tag for drt-react
ngu04 Nov 6, 2024
6be29c2
updating timings
ngu04 Nov 7, 2024
bc13abd
update drt lib for single digit date display
ngu04 Nov 7, 2024
fb927f4
update drt react for endtime
ngu04 Nov 7, 2024
e56f117
fixing 24hr period
ngu04 Nov 7, 2024
5231da6
update drt react
ngu04 Nov 8, 2024
058a42f
Drtii 1681 min staff handle edits (#1948)
richbirch Nov 11, 2024
03dbf74
Drtii 1681 min staff handle edits (#1950)
ngu04 Nov 12, 2024
2f16f95
update drt-react
ngu04 Nov 12, 2024
551911c
merge
ngu04 Nov 12, 2024
820e501
update package json lock to version 1.5.7
ngu04 Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 25 additions & 11 deletions client/src/main/scala/drt/client/components/MonthlyStaffing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import drt.client.logger.{Logger, LoggerFactory}
import drt.client.modules.GoogleEventTracker
import drt.client.services.JSDateConversions.SDate
import drt.client.services.{JSDateConversions, SPACircuit}
import drt.client.util.DateRange
import drt.shared._
import io.kinoplan.scalajs.react.material.ui.core.MuiButton.Color
import io.kinoplan.scalajs.react.material.ui.core.system.SxProps
Expand All @@ -26,7 +27,7 @@ import org.scalajs.dom.html.{Div, Select}
import org.scalajs.dom.window.confirm
import uk.gov.homeoffice.drt.ports.AirportConfig
import uk.gov.homeoffice.drt.ports.Terminals.Terminal
import uk.gov.homeoffice.drt.time.SDateLike
import uk.gov.homeoffice.drt.time.{LocalDate, SDateLike}

import scala.collection.mutable
import scala.scalajs.js
Expand Down Expand Up @@ -305,9 +306,13 @@ object MonthlyStaffing {
)
),
if (props.enableStaffPlanningChanges)
MuiButton(color = Color.primary, variant = "outlined", size = "small", sx = SxProps(Map("backgroundColor" -> "white")))
MuiButton(color = Color.primary,
variant = "outlined",
size = "small",
sx = SxProps(Map("backgroundColor" -> "white")))
(MuiIcons(Groups)(fontSize = "small"),
<.span(^.style := js.Dictionary("paddingLeft" -> "5px"), "Edit staff"),
VdomAttr("data-cy") := "edit-staff-button",
^.onClick ==> handleShiftEditForm)
else EmptyVdom,
MuiButton(color = Color.primary, variant = "contained")
Expand All @@ -331,15 +336,7 @@ object MonthlyStaffing {
ustd = IUpdateStaffForTimeRangeData(startDayAt = Moment.utc(), startTimeAt = Moment.utc(), endTimeAt = Moment.utc(), endDayAt = Moment.utc(), actualStaff = "0"),
interval = props.timeSlotMinutes,
handleSubmit = (ssf: IUpdateStaffForTimeRangeData) => {
val dayInMilliseconds = 1000 * 60 * 60 * 24
val startDay = ssf.startDayAt.utc().toDate().getTime().toLong / dayInMilliseconds // Convert to days
val endDay = ssf.endDayAt.utc().toDate().getTime().toLong / dayInMilliseconds // Convert to days
val staffAssignments: Seq[StaffAssignment] = (startDay to endDay).map { day =>
val dayAt = Moment(day * dayInMilliseconds) // Convert back to milliseconds
val ssfDay = IUpdateStaffForTimeRangeData(dayAt, ssf.startTimeAt, ssf.endTimeAt, dayAt, ssf.actualStaff)
IUpdateStaffForTimeRangeData.toStaffAssignment(ssfDay, props.terminalPageTab.terminal)
}
SPACircuit.dispatch(UpdateShifts(staffAssignments))
SPACircuit.dispatch(UpdateShifts(staffAssignmentsFromForm(ssf, props.terminalPageTab.terminal)))
scope.modState(state => {
val newState = state.copy(showEditStaffForm = false, showStaffSuccess = true)
newState
Expand Down Expand Up @@ -375,6 +372,23 @@ object MonthlyStaffing {
}
}

private def staffAssignmentsFromForm(ssf: IUpdateStaffForTimeRangeData, terminal: Terminal): Seq[StaffAssignment] = {
val startDayLocal = LocalDate(ssf.startDayAt.year(), ssf.startDayAt.month() + 1, ssf.startDayAt.date())
val endDayLocal = LocalDate(ssf.endDayAt.year(), ssf.endDayAt.month() + 1, ssf.endDayAt.date())

val startHour = ssf.startTimeAt.hour()
val startMinute = ssf.startTimeAt.minute()

val endHour = ssf.endTimeAt.hour()
val endMinute = ssf.endTimeAt.minute()

DateRange(startDayLocal, endDayLocal).map { date =>
val startDateTime = SDate(date.year, date.month, date.day, startHour, startMinute)
val endDateTime = SDate(date.year, date.month, date.day, endHour, endMinute)
StaffAssignment(startDateTime.toISOString, terminal, startDateTime.millisSinceEpoch, endDateTime.millisSinceEpoch, ssf.actualStaff.toInt, None)
}
}

private def navigationArrows(props: Props, previousWeekDate: SDateLike, nextWeekDate: SDateLike) = {
<.div(
MuiButton(color = Color.primary, variant = "outlined",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,6 @@ object IUpdateStaffForTimeRangeData {
p.actualStaff = actualStaff
p
}

def toStaffAssignment(obj: IUpdateStaffForTimeRangeData, terminal: Terminal): StaffAssignment = {

val combinedStartTime: Double = new Date(
obj.startDayAt.year(),
obj.startDayAt.month(),
obj.startDayAt.date,
obj.startTimeAt.utc.toDate().getUTCHours.toInt,
obj.startTimeAt.utc.toDate().getUTCMinutes.toInt,
obj.startTimeAt.utc.toDate().getUTCSeconds.toInt
).getTime()

val combinedEndTime: UndefOr[Double] = new Date(
obj.startDayAt.year(),
obj.startDayAt.month(),
obj.startDayAt.date(),
obj.endTimeAt.utc.toDate().getUTCHours.toInt,
obj.endTimeAt.utc.toDate().getUTCMinutes.toInt,
obj.endTimeAt.utc.toDate().getUTCSeconds.toInt
).getTime()

StaffAssignment(obj.startDayAt.toISOString,
terminal,
combinedStartTime.toLong,
combinedEndTime.map(a => a.toLong).getOrElse(combinedStartTime.toLong),
obj.actualStaff.toInt,
None)
}
}

@js.native
Expand All @@ -66,7 +38,7 @@ trait IUpdateStaffForTimeRangeForm extends js.Object {
}

object IUpdateStaffForTimeRangeForm {
def apply(ustd: IUpdateStaffForTimeRangeData, interval:Int, handleSubmit: js.Function1[IUpdateStaffForTimeRangeData, Unit], cancelHandler: js.Function0[Unit]): IUpdateStaffForTimeRangeForm = {
def apply(ustd: IUpdateStaffForTimeRangeData, interval: Int, handleSubmit: js.Function1[IUpdateStaffForTimeRangeData, Unit], cancelHandler: js.Function0[Unit]): IUpdateStaffForTimeRangeForm = {
val p = (new js.Object).asInstanceOf[IUpdateStaffForTimeRangeForm]
p.ustd = ustd
p.handleSubmit = handleSubmit
Expand Down
18 changes: 18 additions & 0 deletions client/src/main/scala/drt/client/util/DateRange.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package drt.client.util

import drt.client.services.JSDateConversions.SDate
import uk.gov.homeoffice.drt.time.{LocalDate, UtcDate}

object DateRange {
def apply(start: LocalDate, end: LocalDate): Seq[LocalDate] =
LazyList
.iterate(SDate(start))(_.addDays(1))
.takeWhile(_.toLocalDate <= end)
.map(_.toLocalDate)

def apply(start: UtcDate, end: UtcDate): Seq[UtcDate] =
LazyList
.iterate(SDate(start))(_.addDays(1))
.takeWhile(_.toUtcDate <= end)
.map(_.toUtcDate)
}
4 changes: 2 additions & 2 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Settings {
/** Declare global dependency versions here to avoid mismatches in multi part dependencies */
//noinspection ScalaStyle
object versions {
val drtLib = "v936"
val drtLib = "v952"

val scala = "2.13.12"
val scalaDom = "2.8.0"
Expand Down Expand Up @@ -99,7 +99,7 @@ object Settings {
"react-markdown" -> "9.0.1",
"@types/react-dom" -> react,
"css-loader" -> "6.7.2",
"@drt/drt-react"-> "https://github.com/UKHomeOffice/drt-react/tree/1.5.6",
"@drt/drt-react"-> "https://github.com/UKHomeOffice/drt-react/tree/1.5.7",
)

/** Dependencies only used by the JS project (note the use of %%% instead of %%) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ case class MockDrtParameters @Inject()() extends DrtParameters {
override val retainDataForYears: Int = 5
override val govNotifyApiKey: String = ""
override val isTestEnvironment: Boolean = true
override val enableStaffPlanningChange: Boolean = false
override val enableStaffPlanningChange: Boolean = true
}

case class MockUserFeedbackDao() extends IUserFeedbackDao {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FeatureFlagsControllerSpec extends PlaySpec {
override val useApiPaxNos = true
override val enableToggleDisplayWaitTimes = true
override val displayRedListInfo = true
override val enableStaffPlanningChange = true
}
}

Expand All @@ -32,7 +33,7 @@ class FeatureFlagsControllerSpec extends PlaySpec {
status(result) mustBe OK

val resultExpected =
s"""{"useApiPaxNos":true,"displayWaitTimesToggle":true,"displayRedListInfo":true,"enableStaffPlanningChange":false}""".stripMargin
s"""{"useApiPaxNos":true,"displayWaitTimesToggle":true,"displayRedListInfo":true,"enableStaffPlanningChange":true}""".stripMargin
.stripMargin

contentAsString(result) must include(resultExpected)
Expand Down
22 changes: 22 additions & 0 deletions server/src/test/scala/drt/shared/ShiftAssignmentsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ object ShiftAssignmentsTest extends Specification {
}
}

"Given a shift that spans 24 hours from midnight" >> {
"Then it should correctly handle the shift" >> {
val startTime = SDate("2024-11-05T00:00:00Z").millisSinceEpoch
val endTime = SDate("2024-11-06T00:00:00Z").millisSinceEpoch
val shift = StaffAssignment("24HourShift", T1, startTime, endTime, 5, None)
val service = ShiftAssignments(Seq(shift))
val msToSdate: MillisSinceEpoch => SDateLike = millis => SDate(millis)

"I should see the shift apply at the start time" >> {
service.terminalStaffAt(T1, SDate("2024-11-05T00:00"), msToSdate) === 5
}
"I should see the shift apply at the 23:30 time" >> {
service.terminalStaffAt(T1, SDate("2024-11-05T23:30"), msToSdate) === 5
}
"I should see the shift apply at the end time" >> {
service.terminalStaffAt(T1, SDate("2024-11-06T00:00"), msToSdate) === 5
}
"I should see the shift apply throughout the 24 hours" >> {
service.terminalStaffAt(T1, SDate("2024-11-05T12:00"), msToSdate) === 5
}
}
}

"Give shift with start and end date" >> {
"Then split a shift into 15 minutes interval shifts" >> {
Expand Down
Loading