Skip to content

Extract a synchronous proofing job#1524

Merged
zachmargolis merged 1 commit intomasterfrom
margolis-proofing-job
Jul 5, 2017
Merged

Extract a synchronous proofing job#1524
zachmargolis merged 1 commit intomasterfrom
margolis-proofing-job

Conversation

@zachmargolis
Copy link
Contributor

Why: One last small refactor step before making the job async

@monfresh
Copy link
Contributor

monfresh commented Jul 3, 2017

Looks like you forgot to pass in the vendor_validator_result argument. There are 12 tests failing with missing keyword: vendor_validator_result.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean perform_later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! I wanted to make this synchronous because then we don't have to touch the UI in this PR. Next PR will be asynchronous

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a better name for this, or split it up into multiple classes if necessary? Adding "Service" to the name of a class is a smell. It's implied that it's a service, so the name of the class should still make sense if you drop "Service" from its name, but VendorValidator would not be an appropriate name for what this class is doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of VendorValidatorService#submit_job, how about a class called SubmitIdvJob with a call method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll go with SubmitIdvJob and turn the other into VendorValidatorResultStorage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e58e2bdf2bc3d1cbccd49ac2bb64bff0e5143bb7

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ABC size is "assignment branch condition" complexity and this method scored too high so I just disabled it, because I thought it was more important to have an equality method we could use in specs to compare things

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the comment on the wrong line. I meant what does the method do? Sounds like it's mainly to facilitate testing? Is this method used anywhere besides tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's just used in tests, I wanted a shorthand for comparing a VendorResult that we reconstructed from redis to compare to the one we put in redis (VendorResultStorage)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of having public methods that are only used in tests. Can this be done using a custom RSpec matcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just remove it and check the attributes manually

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 83af72b1cca3849a97f5e619d1587814c64f63ff

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this TTL get updated or only set once when first called? I'm thinking about the scenario where the user starts proofing at 12:00, this TTL is then set to expire at 12:08, but the user takes longer than that to finish proofing. For example, after they submit the first profile page, let's say the vendor takes a minute to respond. Then, the user stays idle for 7 minutes on the financial info page because they had to go find their credit card. It's now 12:08, but the session is still active because their last request was only 7 minutes ago. So then they enter their credit card, but now the Redis TTL has expired. Will this cause any issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the TTL for the result value of one job.

So for the 3 steps, they will have 3 separate result objects that will have 3 separate expirations.

When this is asynchronous, the result is created after hitting submit and hearing back from the vendor. So as long as the user's browser takes less than this time to refresh the page (which it definitely will, I think we'll set refresh interval to something like 10-15 seconds) then the controller will pick up the result from redis and use it for what it needs to be used and move on to the next step.

Copy link
Contributor

@monfresh monfresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zachmargolis zachmargolis force-pushed the margolis-proofing-job branch 2 times, most recently from a3c4e92 to f758ecb Compare July 5, 2017 20:42
**Why**: One last small refactor step before making the job async
@zachmargolis zachmargolis merged commit 7663dbc into master Jul 5, 2017
@zachmargolis zachmargolis deleted the margolis-proofing-job branch July 6, 2017 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants