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

Introduce a concept of "state" to projects #1473

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

lozette
Copy link
Collaborator

@lozette lozette commented Apr 4, 2024

We want to be able to mark projects as "deleted", but not actually delete the record from the database. We intend to add a deleted state to projects .

Ahead of this, we have decided to add a state to projects, and enumerate it for the various different states a project can be in. For now, this is "active" and "completed"

Add an enumerator to projects - 0 for active (default) and 1 for completed.

As the state is an enumerator, we get the scope Project.completed for free now. Due to Rails magic, we also get Project.not_completed - anything not in the completed state. In the first commit, we keep Project.not_completed as is; in the second, we replace Project.not_completed with the more semantic Project.active.

As the original Project.completed scope had an order (ordering by completed_at date) we have had to split this ordering out and add it as a new scope.

We have added the new state to the project factories, and updated the relevant tests.

Unfortunately this was the smallest single commit we could make for this change.

(No user-facing changes in this commit)

@lozette lozette marked this pull request as ready for review April 4, 2024 12:59
@lozette lozette force-pushed the feature/161543-projects-have-a-state branch 3 times, most recently from 5fc9b20 to d5a21da Compare April 4, 2024 13:28
We want to be able to mark projects as "deleted", but not actually delete
the record from the database. We intend to add a deleted state to projects.

Ahead of this, we have decided to add a `state` to projects, and enumerate it
for the various different states a project can be in. For now, this is "active"
and "completed"

Add an enumerator to projects - 0 for active (default) and 1 for completed.

As the state is an enumerator, we get the scope Project.completed for free now.
Due to Rails magic, we also get Project.not_completed - anything not in the
completed state. For now, this is "active", but in future if we add more states
we will need to make "not complete" more specific (ie if we add a deleted
state, then deleted will also fall under "not completed")

As the original Project.completed scope had an order (ordering by completed_at
date) we have had to split this ordering out and add it as a new scope.

We have added the new state to the project factories, and updated the relevant
tests.

Unfortunately this was the smallest single commit we could make for this
change.
Now that we have the project state as an enumerable, we get Project.active
scope for free and we can use it to replace any instances of
Project.not_completed
@lozette lozette force-pushed the feature/161543-projects-have-a-state branch from d5a21da to f8c0af5 Compare April 5, 2024 15:46
Copy link

sonarcloud bot commented Apr 5, 2024

Copy link
Collaborator

@mec mec left a comment

Choose a reason for hiding this comment

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

🚢

@lozette lozette merged commit 68092e6 into main Apr 9, 2024
7 checks passed
@lozette lozette deleted the feature/161543-projects-have-a-state branch April 9, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants