18F / micropurchase

18F's micro-purchase threshold experiment management app.
https://micropurchase.18f.gov
Other
68 stars 37 forks source link

WIP: Move states into separate tables #1494

Open adelevie opened 7 years ago

adelevie commented 7 years ago

Working with @baccigalupi to pay down some technical debt by moving many of the groupings of fields on Auction into their own state objects. The disambiguation will make the code easier to reason about, and easier to modify as state needs change.

adelevie commented 7 years ago

An idea for a state builder:

ChangeState.new(auction, published: :unpublished).perform

Although maybe raw ActiveRecord is still fine. The abstractions don't seem to abstract too much other than the column names of AuctionState, which I'm not even sure need to be hidden.

UPDATE

Ended up writing something close:

ChangeState.new(auction, 'published', 'unpublished').perform

This helps simplify UpdateAuction in that UpdateAuction#create_auction_states no longer needs to know about whether or not an AuctionState needs to be created or found-and-updated. This will be handy as we add more state changes to UpdateAuction.