Skip to content

Commit

Permalink
Merge branch 'integrationTesting' into INT-B-19902-move-gets-locked-w…
Browse files Browse the repository at this point in the history
…hen-office-user-enters-and-ui-changes
  • Loading branch information
danieljordan-caci authored May 10, 2024
2 parents fe1fc78 + 4201dc6 commit 7be1f82
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 92 deletions.
2 changes: 2 additions & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -927,3 +927,5 @@
20240502175909_add_lookup_valid_columns_to_tac_and_loa_tables.up.sql
20240502183613_add_support_for_standalone_payment_cap.up.sql
20240503123556_add_diversion_reason_to_mto_shipments.up.sql
20240506214039_add_submitted_columns_to_ppm_document_tables.up.sql
20240507133524_add_locked_moves_column_to_moves_table.up.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ALTER TABLE application_parameters
ADD COLUMN IF NOT EXISTS parameter_name TEXT NOT NULL,
ADD COLUMN IF NOT EXISTS parameter_value TEXT NOT NULL,
ADD COLUMN IF NOT EXISTS parameter_name TEXT,
ADD COLUMN IF NOT EXISTS parameter_value TEXT,
ALTER COLUMN validation_code DROP NOT NULL;

COMMENT ON COLUMN application_parameters.parameter_name IS 'The name of the parameter';
COMMENT ON COLUMN application_parameters.parameter_value IS 'The value of the parameter';
COMMENT ON COLUMN application_parameters.parameter_value IS 'The value of the parameter';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ALTER TABLE weight_tickets
ADD COLUMN IF NOT EXISTS submitted_empty_weight INT4 DEFAULT NULL,
ADD COLUMN IF NOT EXISTS submitted_full_weight INT4 DEFAULT NULL;

COMMENT ON COLUMN weight_tickets.submitted_empty_weight IS 'Stores the customer submitted empty_weight.';
COMMENT ON COLUMN weight_tickets.submitted_full_weight IS 'Stores the customer submitted full_weight.';

ALTER TABLE progear_weight_tickets ADD COLUMN IF NOT EXISTS submitted_weight INT4 DEFAULT NULL;

COMMENT ON COLUMN progear_weight_tickets.submitted_weight IS 'Stores the customer submitted weight.';

ALTER TABLE moving_expenses
ADD COLUMN IF NOT EXISTS submitted_amount INT4 DEFAULT NULL,
ADD COLUMN IF NOT EXISTS submitted_sit_start_date DATE DEFAULT NULL,
ADD COLUMN IF NOT EXISTS submitted_sit_end_date DATE DEFAULT NULL;

COMMENT ON COLUMN moving_expenses.submitted_amount IS 'Stores the customer submitted amount.';
COMMENT ON COLUMN moving_expenses.submitted_sit_start_date IS 'Stores the customer submitted sit_start_date.';
COMMENT ON COLUMN moving_expenses.submitted_sit_end_date IS 'Stores the customer submitted sit_end_date.';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- These column additions will handle locking a move
-- when an office user is working on them
-- Add columns if they don't exist
ALTER TABLE moves
ADD COLUMN IF NOT EXISTS locked_by UUID NULL,
ADD COLUMN IF NOT EXISTS lock_expires_at TIMESTAMP WITH TIME ZONE NULL;

-- Add foreign key constraint to office_users table
ALTER TABLE moves
ADD CONSTRAINT fk_locked_by
FOREIGN KEY (locked_by)
REFERENCES office_users(id);

-- Add comments for the columns
COMMENT ON COLUMN moves.locked_by IS 'The id of the office user that locked the move.';
COMMENT ON COLUMN moves.lock_expires_at IS 'The expiration time that a move is locked until, the default value of this will be 30 minutes from initial lock.';
12 changes: 8 additions & 4 deletions pkg/gen/internalapi/embedded_spec.go

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

4 changes: 2 additions & 2 deletions pkg/gen/internalmessages/application_parameters.go

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

10 changes: 7 additions & 3 deletions pkg/handlers/internalapi/application_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import (
)

func payloadForApplicationParametersModel(v models.ApplicationParameters) internalmessages.ApplicationParameters {

parameterValue := v.ParameterValue
parameterName := v.ParameterName

payload := internalmessages.ApplicationParameters{
ParameterValue: *handlers.FmtString(v.ParameterValue),
ParameterName: *handlers.FmtString(v.ParameterName),
ParameterValue: parameterValue,
ParameterName: parameterName,
}
return payload
}
Expand All @@ -34,7 +38,7 @@ func (h ApplicationParametersValidateHandler) Handle(params application_paramete
name := params.Body.ParameterName

// fetch the value, if not found it will be an empty string
result, _ := models.FetchParameterValue(appCtx.DB(), value, name)
result, _ := models.FetchParameterValue(appCtx.DB(), *name, *value)

parameterValuePayload := payloadForApplicationParametersModel(result)

Expand Down
6 changes: 4 additions & 2 deletions pkg/handlers/internalapi/application_parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ func (suite *HandlerSuite) TestApplicationParametersValidateHandler() {
req := httptest.NewRequest("POST", "/application_parameters", nil)
req = suite.AuthenticateUserRequest(req, user)

validationCode := "validation_code"
testCode := "Testcode123123"
body := internalmessages.ApplicationParameters{
ParameterValue: "TestCode123123",
ParameterName: "validation_code",
ParameterName: &validationCode,
ParameterValue: &testCode,
}

params := application_parameters.ValidateParams{
Expand Down
12 changes: 6 additions & 6 deletions pkg/models/application_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
type ApplicationParameters struct {
ID uuid.UUID `json:"id" db:"id"`
ValidationCode *string `json:"validation_code" db:"validation_code"`
ParameterName string `json:"parameter_name" db:"parameter_name"`
ParameterValue string `json:"parameter_value" db:"parameter_value"`
ParameterName *string `json:"parameter_name" db:"parameter_name"`
ParameterValue *string `json:"parameter_value" db:"parameter_value"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
Expand All @@ -23,9 +23,9 @@ func (a ApplicationParameters) TableName() string {
}

// FetchParameterValue returns a specific parameter value from the db
func FetchParameterValue(db *pop.Connection, code string, value string) (ApplicationParameters, error) {
var parameterValue ApplicationParameters
err := db.Q().Where(`parameter_value=$1 AND parameter_name=$2`, code, value).First(&parameterValue)
func FetchParameterValue(db *pop.Connection, param string, value string) (ApplicationParameters, error) {
var parameter ApplicationParameters
err := db.Q().Where(`parameter_name=$1 AND parameter_value=$2`, param, value).First(&parameter)
// if it isn't found, we'll return an empty object
if err != nil {
if errors.Cause(err).Error() == RecordNotFoundErrorString {
Expand All @@ -34,5 +34,5 @@ func FetchParameterValue(db *pop.Connection, code string, value string) (Applica
return ApplicationParameters{}, err
}

return parameterValue, nil
return parameter, nil
}
14 changes: 9 additions & 5 deletions pkg/models/application_parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ import (
)

func (suite *ModelSuite) Test_FetchParameterValue() {
param := "validation_code"
value := "Testcode123123"
parameterValue := models.ApplicationParameters{
ID: uuid.Must(uuid.NewV4()),
ParameterName: "validation_code",
ParameterValue: "TestCode123123",
ParameterName: &param,
ParameterValue: &value,
}
suite.MustCreate(&parameterValue)

// if the value is found, it should return the same code provided
shouldHaveValue, err := models.FetchParameterValue(suite.DB(), "TestCode123123", "validation_code")
shouldHaveValue, err := models.FetchParameterValue(suite.DB(), param, value)
suite.NoError(err)
suite.Equal(parameterValue.ParameterValue, shouldHaveValue.ParameterValue)

// if the value is not found, it should return an empty string
shouldNotHaveValue, err := models.FetchParameterValue(suite.DB(), "TestCode123456", "validation_code")
wrongValue := "Testcode123456"
var nilString *string = nil
shouldNotHaveValue, err := models.FetchParameterValue(suite.DB(), param, wrongValue)
suite.NoError(err)
suite.Equal("", shouldNotHaveValue.ParameterValue)
suite.Equal(nilString, shouldNotHaveValue.ParameterValue)
}
4 changes: 4 additions & 0 deletions pkg/services/order/order_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/transcom/mymove/pkg/apperror"
"github.com/transcom/mymove/pkg/db/utilities"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/models/roles"
"github.com/transcom/mymove/pkg/services"
)

Expand Down Expand Up @@ -163,6 +164,9 @@ func (f orderFetcher) ListOrders(appCtx appcontext.AppContext, officeUserID uuid
Where("(ppm_shipments.status IS NULL OR ppm_shipments.status NOT IN (?))", models.PPMShipmentStatusWaitingOnCustomer, models.PPMShipmentStatusNeedsPaymentApproval, models.PPMShipmentStatusPaymentApproved)
}
} else {
if appCtx.Session().Roles.HasRole(roles.RoleTypeTOO) {
query.Where("(moves.ppm_type = 'PARTIAL' or (moves.ppm_type = 'FULL' and origin_dl.provides_services_counseling = 'false'))")
}
// TODO not sure we'll need this once we're in a situation where closeout param is always passed
query.LeftJoin("ppm_shipments", "ppm_shipments.shipment_id = mto_shipments.id")
}
Expand Down
Loading

0 comments on commit 7be1f82

Please sign in to comment.