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 22087 int - Number of shipments in the search queue not decreasing when shipments are deleted #14865

Merged
merged 34 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
959e258
Bump store2 from 2.14.2 to 2.14.4
dependabot[bot] Feb 4, 2025
c9ac4c2
move search will not include any canceled, deleted, or rejected ship…
JonSpight Feb 20, 2025
9e64d13
removed space
JonSpight Feb 20, 2025
d92e39e
Merge branch 'B-22087-main' into B-22087-int
JonSpight Feb 21, 2025
7ad4c72
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22039-r…
ryan-mchugh Feb 25, 2025
af822a2
do not count deleted shipments
JonSpight Feb 26, 2025
382affb
Merge branch 'main' into B-22087-main
JonSpight Feb 26, 2025
f696610
comment removal
JonSpight Feb 27, 2025
a80eb5c
fixed check on draft status
JonSpight Feb 27, 2025
47f022c
removal delete empty shipment attempt
JonSpight Feb 27, 2025
a81739e
Merge branch 'main' into B-22087-main
JonSpight Feb 27, 2025
f922aef
Mtoshipment filter
JonSpight Feb 28, 2025
fe99d08
moved FilterMtoShipments to mto_shipments
JonSpight Feb 28, 2025
7fa7ca7
comment removal
JonSpight Feb 28, 2025
8191575
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22039-r…
ryan-mchugh Feb 28, 2025
a727373
Updated filter & test cases
JonSpight Feb 28, 2025
4b5ce4c
Merge branch 'main' into B-22087-main
JonSpight Feb 28, 2025
e14da67
Merge branch 'integrationTesting' into B-22087-int
JonSpight Feb 28, 2025
f94ebfe
Merge branch 'B-22087-main' into B-22087-int
JonSpight Feb 28, 2025
29c9e8a
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-22039-r…
ryan-mchugh Feb 28, 2025
3ebb152
Merge branch 'main' into MAIN-B-22039-remove_lat_lon
brianmanley-caci Mar 3, 2025
be8a59a
Merge branch 'main' into MAIN-B-22039-remove_lat_lon
brianmanley-caci Mar 3, 2025
d13d25a
Merge pull request #14924 from transcom/MAIN-B-22039-remove_lat_lon
brianmanley-caci Mar 3, 2025
ee30031
Merge branch 'main' into dependabot/npm_and_yarn/store2-2.14.4
deandreJones Mar 3, 2025
dc3fd38
Merge pull request #14660 from transcom/dependabot/npm_and_yarn/store…
deandreJones Mar 3, 2025
3160cc8
canelled -> canceled
JonSpight Mar 4, 2025
5f35948
Merge branch 'B-22087-main' into B-22087-int
JonSpight Mar 4, 2025
d4b10fb
Merge branch 'main' into B-22087-main
JonSpight Mar 4, 2025
c69bb05
Merge branch 'integrationTesting' into B-22087-int
JonSpight Mar 4, 2025
3dadb58
removed filter on cancelation request
JonSpight Mar 4, 2025
381879a
Merge branch 'B-22087-main' into B-22087-int
JonSpight Mar 4, 2025
c96beac
updated comments and tests for cancelled request removal
JonSpight Mar 4, 2025
942375b
Merge branch 'B-22087-main' into B-22087-int
JonSpight Mar 4, 2025
4f4b002
Merge branch 'integrationTesting' into B-22087-int
JonSpight Mar 4, 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
8 changes: 1 addition & 7 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2633,13 +2633,7 @@ func SearchMoves(appCtx appcontext.AppContext, moves models.Moves) *ghcmessages.
for i, move := range moves {
customer := move.Orders.ServiceMember

numShipments := 0

for _, shipment := range move.MTOShipments {
if shipment.Status != models.MTOShipmentStatusDraft {
numShipments++
}
}
numShipments := len(move.MTOShipments)

var pickupDate, deliveryDate *strfmt.Date

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ func (suite *PayloadsSuite) TestSearchMoves() {
},
},
}, nil)

moves := models.Moves{moveUSMC}
suite.Run("Success - Returns a ghcmessages Upload payload from Upload Struct Marine move with no shipments", func() {
payload := SearchMoves(appCtx, moves)
Expand Down
20 changes: 20 additions & 0 deletions pkg/models/mto_shipments.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,23 @@ func FetchShipmentByID(db *pop.Connection, shipmentID uuid.UUID) (*MTOShipment,
}
return &mtoShipment, nil
}

// filters the returned MtoShipments for each move.
// Ignoring mto shipments that have been deleted, cancelled, or rejected.
func FilterDeletedRejectedCanceledMtoShipments(unfilteredShipments MTOShipments) MTOShipments {
if len(unfilteredShipments) == 0 {
return unfilteredShipments
}

filteredShipments := MTOShipments{}
for _, shipment := range unfilteredShipments {
if shipment.DeletedAt == nil &&
(shipment.Status != MTOShipmentStatusDraft) &&
(shipment.Status != MTOShipmentStatusRejected) &&
(shipment.Status != MTOShipmentStatusCanceled) {
filteredShipments = append(filteredShipments, shipment)
}
}

return filteredShipments
}
8 changes: 7 additions & 1 deletion pkg/services/move/move_searcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s moveSearcher) SearchMoves(appCtx appcontext.AppContext, params *services
Join("addresses as origin_addresses", "origin_addresses.id = origin_duty_locations.address_id").
Join("duty_locations as new_duty_locations", "new_duty_locations.id = orders.new_duty_location_id").
Join("addresses as new_addresses", "new_addresses.id = new_duty_locations.address_id").
LeftJoin("mto_shipments", "mto_shipments.move_id = moves.id AND mto_shipments.status <> 'DRAFT'").
LeftJoin("mto_shipments", "mto_shipments.move_id = moves.id").
LeftJoin("move_to_gbloc", "move_to_gbloc.move_id = moves.id").
GroupBy("moves.id", "service_members.id", "origin_addresses.id", "new_addresses.id").
Where("show = TRUE")
Expand Down Expand Up @@ -105,6 +105,12 @@ func (s moveSearcher) SearchMoves(appCtx appcontext.AppContext, params *services
if err != nil {
return models.Moves{}, 0, apperror.NewQueryError("Move", err, "")
}

for i := range moves {
if moves[i].MTOShipments != nil {
moves[i].MTOShipments = models.FilterDeletedRejectedCanceledMtoShipments(moves[i].MTOShipments)
}
}
return moves, query.Paginator.TotalEntriesSize, nil
}

Expand Down
91 changes: 91 additions & 0 deletions pkg/services/move/move_searcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,97 @@ func (suite *MoveServiceSuite) TestMoveSearch() {
suite.Equal(secondMove.Locator, moves[0].Locator)
suite.Equal(2, totalCount)
})
suite.Run("filtering mto shipments search results", func() {
qaeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeQae})

session := auth.Session{
ApplicationName: auth.OfficeApp,
Roles: qaeUser.User.Roles,
OfficeUserID: qaeUser.ID,
IDToken: "fake_token",
AccessToken: "fakeAccessToken",
}

moveWithShipmentsOfEveryStatus := factory.BuildMove(suite.DB(), []factory.Customization{
{
Model: models.Move{
Locator: "AAAAAA",
},
},
}, nil)

shipmentWithSubmittedStatus := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: moveWithShipmentsOfEveryStatus,
LinkOnly: true,
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusSubmitted,
},
},
}, nil)
shipmentWithCanceledStatus := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: moveWithShipmentsOfEveryStatus,
LinkOnly: true,
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusCanceled,
},
},
}, nil)
rejectionReason := "bad shipment"
shipmentWithRejectedStatus := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: moveWithShipmentsOfEveryStatus,
LinkOnly: true,
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusRejected,
RejectionReason: &rejectionReason,
},
},
}, nil)
shipmentWithCancellationRequestedStatus := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: moveWithShipmentsOfEveryStatus,
LinkOnly: true,
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusCancellationRequested,
},
},
}, nil)
shipmentWithApprovedStatus := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: moveWithShipmentsOfEveryStatus,
LinkOnly: true,
},
{
Model: models.MTOShipment{
Status: models.MTOShipmentStatusApproved,
},
},
}, nil)
moveWithShipmentsOfEveryStatus.MTOShipments = models.MTOShipments{
shipmentWithSubmittedStatus,
shipmentWithCanceledStatus,
shipmentWithRejectedStatus,
shipmentWithCancellationRequestedStatus,
shipmentWithApprovedStatus,
}
filteredShipments := models.FilterDeletedRejectedCanceledMtoShipments(moveWithShipmentsOfEveryStatus.MTOShipments)
moves, _, err := searcher.SearchMoves(suite.AppContextWithSessionForTest(&session), &services.SearchMovesParams{Locator: &moveWithShipmentsOfEveryStatus.Locator})
suite.NoError(err)
suite.Len(moves, 1)
suite.Len(moves[0].MTOShipments, 3)
suite.Equal(len(filteredShipments), 3)

})
}

func setupTestData(suite *MoveServiceSuite) (models.Move, models.Move, models.MTOShipment) {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16502,9 +16502,9 @@ stop-iteration-iterator@^1.0.0:
internal-slot "^1.0.4"

store2@^2.14.2:
version "2.14.2"
resolved "https://registry.yarnpkg.com/store2/-/store2-2.14.2.tgz#56138d200f9fe5f582ad63bc2704dbc0e4a45068"
integrity sha512-siT1RiqlfQnGqgT/YzXVUNsom9S0H1OX+dpdGN1xkyYATo4I6sep5NmsRD/40s3IIOvlCq6akxkqG82urIZW1w==
version "2.14.4"
resolved "https://registry.yarnpkg.com/store2/-/store2-2.14.4.tgz#81b313abaddade4dcd7570c5cc0e3264a8f7a242"
integrity sha512-srTItn1GOvyvOycgxjAnPA63FZNwy0PTyUBFMHRM+hVFltAeoh0LmNBz9SZqUS9mMqGk8rfyWyXn3GH5ReJ8Zw==

storybook@^7.6.20:
version "7.6.20"
Expand Down