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

B 22129 INT closeout data #14540

Merged
merged 24 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9e223b7
start of closeout bulk data
loganwc Jan 2, 2025
b6a8603
closeout queue bulk data
loganwc Jan 8, 2025
7907d67
Merge branch 'main' into B-22129-Closeout-Data
loganwc Jan 8, 2025
0a73f73
Merge B-22129
loganwc Jan 8, 2025
1a9c2b9
undo bad merge conflicts
loganwc Jan 8, 2025
541543b
add test
loganwc Jan 8, 2025
03fe2c6
Merge branch 'B-22129-Closeout-Data' into B-22129-INT-Closeout-Data
loganwc Jan 8, 2025
f857228
Merge integrationTesting
loganwc Jan 9, 2025
d6ede34
Merge branch 'integrationTesting' into B-22129-INT-Closeout-Data
loganwc Jan 9, 2025
5f6999c
now fetches NAVY/USMC/USCG moves for those office users
loganwc Jan 9, 2025
2539197
Merge branch 'B-22129-Closeout-Data' into B-22129-INT-Closeout-Data
loganwc Jan 9, 2025
98d0049
Merge main
loganwc Jan 14, 2025
96ec072
Merge branch 'integrationTesting' into B-22129-INT-Closeout-Data
loganwc Jan 14, 2025
940fbc6
merge B-22129
loganwc Jan 14, 2025
d7f7229
merge conflict things
loganwc Jan 14, 2025
bb9bef0
merge conflict things
loganwc Jan 14, 2025
1262e31
separate usmc usn uscg
loganwc Jan 14, 2025
9b9b600
Merge branch 'B-22129-Closeout-Data' into B-22129-INT-Closeout-Data
loganwc Jan 14, 2025
5d1ee5d
don't need the coalesce in the query
loganwc Jan 15, 2025
ef57fc3
Merge branch 'B-22129-Closeout-Data' into B-22129-INT-Closeout-Data
loganwc Jan 15, 2025
f2baf1e
Merge branch 'integrationTesting' into B-22129-INT-Closeout-Data
loganwc Jan 15, 2025
eaeb267
tests and such
loganwc Jan 21, 2025
61be6a1
merge B-22129
loganwc Jan 21, 2025
37d5684
Merge branch 'integrationTesting' into B-22129-INT-Closeout-Data
loganwc Jan 21, 2025
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
6 changes: 4 additions & 2 deletions pkg/gen/ghcapi/embedded_spec.go

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

2 changes: 1 addition & 1 deletion pkg/gen/ghcmessages/available_office_user.go

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

21 changes: 21 additions & 0 deletions pkg/handlers/ghcapi/queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,27 @@ func (h GetBulkAssignmentDataHandler) Handle(
return queues.NewGetBulkAssignmentDataInternalServerError(), err
}

officeUserData = payloads.BulkAssignmentData(appCtx, moves, officeUsers, officeUser.TransportationOffice.ID)
case string(models.QueueTypeCloseout):
// fetch the Services Counselors who work at their office
officeUsers, err := h.OfficeUserFetcherPop.FetchOfficeUsersWithWorkloadByRoleAndOffice(
appCtx,
roles.RoleTypeServicesCounselor,
officeUser.TransportationOfficeID,
)
if err != nil {
appCtx.Logger().Error("Error retreiving office users", zap.Error(err))
return queues.NewGetBulkAssignmentDataInternalServerError(), err
}
// fetch the moves available to be assigned to their office users
moves, err := h.MoveFetcherBulkAssignment.FetchMovesForBulkAssignmentCloseout(
appCtx, officeUser.TransportationOffice.Gbloc, officeUser.TransportationOffice.ID,
)
if err != nil {
appCtx.Logger().Error("Error retreiving moves", zap.Error(err))
return queues.NewGetBulkAssignmentDataInternalServerError(), err
}
loganwc marked this conversation as resolved.
Show resolved Hide resolved

officeUserData = payloads.BulkAssignmentData(appCtx, moves, officeUsers, officeUser.TransportationOffice.ID)
case string(models.QueueTypeTaskOrder):
// fetch the TOOs who work at their office
Expand Down
1 change: 1 addition & 0 deletions pkg/services/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type MoveFetcher interface {

type MoveFetcherBulkAssignment interface {
FetchMovesForBulkAssignmentCounseling(appCtx appcontext.AppContext, gbloc string, officeId uuid.UUID) ([]models.MoveWithEarliestDate, error)
FetchMovesForBulkAssignmentCloseout(appCtx appcontext.AppContext, gbloc string, officeId uuid.UUID) ([]models.MoveWithEarliestDate, error)
FetchMovesForBulkAssignmentTaskOrder(appCtx appcontext.AppContext, gbloc string, officeId uuid.UUID) ([]models.MoveWithEarliestDate, error)
}

Expand Down
54 changes: 54 additions & 0 deletions pkg/services/move/move_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,60 @@ func (f moveFetcherBulkAssignment) FetchMovesForBulkAssignmentCounseling(appCtx
return moves, nil
}

func (f moveFetcherBulkAssignment) FetchMovesForBulkAssignmentCloseout(appCtx appcontext.AppContext, gbloc string, officeId uuid.UUID) ([]models.MoveWithEarliestDate, error) {
loganwc marked this conversation as resolved.
Show resolved Hide resolved
var moves []models.MoveWithEarliestDate

ppmCloseoutGblocs := gbloc == "NAVY" || gbloc == "TVCB" || gbloc == "USCG"

query := `SELECT
moves.id,
COALESCE(ppm_shipments.expected_departure_date, '9999-12-31') AS earliest_date
loganwc marked this conversation as resolved.
Show resolved Hide resolved
FROM moves
INNER JOIN orders ON orders.id = moves.orders_id
INNER JOIN service_members ON service_members.id = orders.service_member_id
INNER JOIN mto_shipments ON mto_shipments.move_id = moves.id
INNER JOIN ppm_shipments ON ppm_shipments.shipment_id = mto_shipments.id
WHERE
(moves.status IN ('APPROVED', 'SERVICE COUNSELING COMPLETED'))
AND moves.show = $1
AND moves.sc_assigned_id IS NULL
`
if !ppmCloseoutGblocs {
query += ` AND moves.closeout_office_id = '` + officeId.String() + `'
AND (service_members.affiliation NOT IN ('` +
string(models.AffiliationNAVY) + `', '` +
string(models.AffiliationMARINES) + `', '` +
string(models.AffiliationCOASTGUARD) + `'))`
} else {
query += ` AND (service_members.affiliation IN ('` +
loganwc marked this conversation as resolved.
Show resolved Hide resolved
string(models.AffiliationNAVY) + `', '` +
string(models.AffiliationMARINES) + `', '` +
string(models.AffiliationCOASTGUARD) + `'))`
}

query += ` AND (ppm_shipments.status IN ($2))
AND (orders.orders_type NOT IN ($3, $4, $5))
GROUP BY moves.id, ppm_shipments.expected_departure_date
ORDER BY earliest_date ASC`

err := appCtx.DB().RawQuery(query,
models.BoolPointer(true),
models.PPMShipmentStatusNeedsCloseout,
internalmessages.OrdersTypeBLUEBARK,
internalmessages.OrdersTypeWOUNDEDWARRIOR,
internalmessages.OrdersTypeSAFETY).All(&moves)

if err != nil {
return nil, fmt.Errorf("error fetching moves for office: %s with error %w", officeId, err)
}

if len(moves) < 1 {
return nil, nil
}

return moves, nil
}

func (f moveFetcherBulkAssignment) FetchMovesForBulkAssignmentTaskOrder(appCtx appcontext.AppContext, gbloc string, officeId uuid.UUID) ([]models.MoveWithEarliestDate, error) {
var moves []models.MoveWithEarliestDate

Expand Down
79 changes: 79 additions & 0 deletions pkg/services/move/move_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,85 @@ func (suite *MoveServiceSuite) TestMoveFetcherBulkAssignment() {
suite.Equal(assignedMove.Orders.OrdersType, internalmessages.OrdersTypePERMANENTCHANGEOFSTATION)
})

suite.Run("Closeout returns non Navy/USCG/USMC ppms in needs closeout status", func() {
moveFetcher := NewMoveFetcherBulkAssignment()
transportationOffice := factory.BuildTransportationOffice(suite.DB(), nil, nil)
officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{
{
Model: transportationOffice,
LinkOnly: true,
Type: &factory.TransportationOffices.CloseoutOffice,
},
}, []roles.RoleType{roles.RoleTypeServicesCounselor})

// create non USMC/USCG/NAVY ppm in need closeout status
factory.BuildMoveWithPPMShipment(suite.DB(), []factory.Customization{
{
Model: transportationOffice,
LinkOnly: true,
Type: &factory.TransportationOffices.CloseoutOffice,
},
{
Model: models.PPMShipment{
Status: models.PPMShipmentStatusNeedsCloseout,
},
},
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
}, nil)

// create non closeout needed ppm
factory.BuildMoveWithPPMShipment(suite.DB(), []factory.Customization{
{
Model: transportationOffice,
LinkOnly: true,
Type: &factory.TransportationOffices.CloseoutOffice,
},
{
Model: models.PPMShipment{
Status: models.PPMShipmentStatusWaitingOnCustomer,
},
},
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
}, nil)

marine := models.AffiliationMARINES
marinePPM := factory.BuildPPMShipment(suite.DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: models.MTOShipment{
ShipmentType: models.MTOShipmentTypePPM,
},
},
{
Model: models.PPMShipment{
Status: models.PPMShipmentStatusNeedsCloseout,
},
},
{
Model: models.ServiceMember{
Affiliation: &marine,
},
},
}, nil)

moves, err := moveFetcher.FetchMovesForBulkAssignmentCloseout(suite.AppContextForTest(), "KKFA", officeUser.TransportationOffice.ID)
suite.FatalNoError(err)
suite.Equal(1, len(moves))
suite.NotEqual(marinePPM.ID, moves[0].ID)
})

suite.Run("TOO: Returns moves that fulfill the query criteria", func() {
moveFetcher := NewMoveFetcherBulkAssignment()
transportationOffice := factory.BuildTransportationOffice(suite.DB(), nil, nil)
Expand Down
1 change: 1 addition & 0 deletions swagger-def/ghc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7198,6 +7198,7 @@ definitions:
type: boolean
workload:
type: integer
x-omitempty: false
BulkAssignmentData:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions swagger/ghc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7555,6 +7555,7 @@ definitions:
type: boolean
workload:
type: integer
x-omitempty: false
BulkAssignmentData:
type: object
properties:
Expand Down
Loading