order から register, placement(s) から order(s) へ命名を変更する#104
Merged
exflikt merged 6 commits intotut-cc:mainfrom Dec 27, 2024
Merged
order から register, placement(s) から order(s) へ命名を変更する#104exflikt merged 6 commits intotut-cc:mainfrom
order から register, placement(s) から order(s) へ命名を変更する#104exflikt merged 6 commits intotut-cc:mainfrom
Conversation
"Order" has become a pretty overloaded term in this project. In the following commits, I introduce a few renames in hope to reduce various terminology confusions. This first commit renames the `/order` path operations to `/register`. I chose the term "register" because the page acts kind of like a cash register: the page presents various buttons to properly handle incoming order requests. This clears up the distinction between the register as a machine and order sessions as intermediate states.
Although we could say "place an order" to mean registering an order, "placement," in and of itself, does not have the notion of product orders. Yet, I have been using "placement" to mean registered orders. As such, I decided to rename "placement" to simply "order." This renaming revolves around mainly four things: - Path operations and Jinja macros - `placement_t` dictionary - SQLModel definitions - Database tables This commit addresses the first piece. Changes to path operation names are: - `s#/placements/(incoming|resolved)#/orders/&1#` - `s#/placed-items/incoming#/ordered-items/incoming#` - `s#/placements#/orders`
Constraint names are required to properly downgrade foreign key constraints: https://alembic.sqlalchemy.org/en/latest/naming.html In order to make Alembic migrations work in tandem with SQLModel, I had to modify the metadata object managed internally in the SQLModel namespace. The code is partially inspired by this comment (by the way, who's Dan?): https://www.github.com/fastapi/sqlmodel/issues/85#issuecomment-1380418653
I should have named these "orders" and "ordered_items" from the start. Also, "placement_id" and "placed_at" columns are renamed to "order_id" and "ordered_at," respectively. Alembic provides operations for renaming tables, columns, and constraints. That said, I had to write down the migration functions myself because Alembic does not recognize the previous name corresponds to the changed name so automatic script generation did not help much. The execution order is important, and very subtle. The lesson learned: renaming stringly-typed things is hard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #88
placement(s)という単語の使用を廃止し、完了した注文はこれからorder(s)を用います。"placement"という単語自体には注文の意味がなく、"place an order" というフレーズになって初めて注文の意味が現れます。このままだと混乱を招く可能性があります。そのため、元々注文ページのことを指すために使用していた"order" を "register"に言い換えることでorderを完了した注文に当てはめるよう命名を変更しました。以下、変更前の命名と変更後の命名の対応表です。
order(注文ページ)からregister(注文を受け付けるレジ) への命名変更:order(products, session)register(products, session)placement(s)(確定注文) からorder(s)(注文) への命名変更:incoming_placements(placements)incoming_orders(orders)resolved_placements(placements)resolved_orders(orders)placed_item(s)(確定したアイテム) からordered_item(s)(注文されたアイテム) への命名変更:placed_items_incoming(placed_items)ordered_items_incoming(ordered_items)