Skip to content

Dashboard Events #348

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

Merged
merged 12 commits into from
May 18, 2018
Merged

Dashboard Events #348

merged 12 commits into from
May 18, 2018

Conversation

mllocs
Copy link
Collaborator

@mllocs mllocs commented May 1, 2018

WAT

Using the Persisters to create Events. See #347.

Test

  • Create and update a post (offer and inquiries)
  • Create and update a transfer
  • Create and update a member (add and remove members for orgs basically)

@mllocs mllocs requested review from enricostano and sauloperez May 1, 2018 12:18
Copy link
Contributor

@enricostano enricostano left a comment

Choose a reason for hiding this comment

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

Nice POC! 💪


private

# Validates that only one resourece id is set
Copy link
Contributor

Choose a reason for hiding this comment

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

s/resourece/resource

Copy link
Collaborator

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

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

Looking pretty good! tests and 👍

belongs_to :member
belongs_to :transfer

validates :action, inclusion: { :in => ACTIONS }, presence: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 that #️⃣ 🚀

@mllocs mllocs changed the base branch from feature/introducing-post-persister to develop May 7, 2018 18:31
@mllocs mllocs force-pushed the feature/dashboard-events branch from 00776b2 to d746b62 Compare May 7, 2018 18:31
db/schema.rb Outdated
@@ -76,6 +76,9 @@
add_index "documents", ["documentable_id", "documentable_type"], name: "index_documents_on_documentable_id_and_documentable_type", using: :btree
add_index "documents", ["label"], name: "index_documents_on_label", using: :btree

# Could not dump table "events" because of following StandardError
# Unknown type 'action_enum' for column 'action'

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ a solution is to stop using db/schema.rb and start using db/structure.sql, let's talk about it

cc/ @sauloperez

Copy link
Contributor

Choose a reason for hiding this comment

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

Another solution is to use the AR built in enum, basically storing an integer instead of a string (classic Rails approach with validation only at model level) or ENUM (DB check level I'm proposing)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we are safe enough using AR enum :)

Copy link
Contributor

Choose a reason for hiding this comment

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

There is another option using AR enum storing integer as I said AND adding check inclusion instead of PG enum. Will propose this option as it seems a good tradeoff to me

transfer_id integer REFERENCES transfers,
created_at timestamp without time zone,
updated_at timestamp without time zone,
CHECK(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would only do this in SQL by means of an ALTER TABLE. This way we keep the rest using Rails' DSL, which might be easier to read for other devs.

@mllocs
Copy link
Collaborator Author

mllocs commented May 13, 2018

Events and Dashboard

@markets
Copy link
Collaborator

markets commented May 13, 2018

nice feature here team 👏 🔝

As @mllocs and @sauloperez pointed out, I'd stick with simpler solutions like:

a) string + model validation (inclusion)
b) AR enum

I think both options give us enough data integrity and seems an approach more easy to follow for more people.

@rewritten
Copy link
Contributor

rewritten commented May 13, 2018 via email

@enricostano enricostano force-pushed the feature/dashboard-events branch from afcb387 to 43a0f4f Compare May 16, 2018 08:23
@enricostano enricostano dismissed their stale review May 16, 2018 08:23

Conflict of interests 😂

member_id integer REFERENCES members,
transfer_id integer REFERENCES transfers,
created_at timestamp without time zone,
updated_at timestamp without time zone,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I left I comment about this already but it got collapsed. What about having the regular create_table and then an alter table for these checks that can't be done with AR? I think this would make it a bit more clear that we specify things AR does not provide and perhaps a bit more readable.

@@ -0,0 +1,39 @@
# This migration does not use Rails ActiveRecord ORM DSL since
# it doesn't provide data integrity (foreign key) for polymorphic models.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I fully understand what you mean.

Copy link
Contributor

Choose a reason for hiding this comment

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

Read the article 😂

@sseerrggii
Copy link
Contributor

sseerrggii commented May 17, 2018

Tested

CRUD

  • Offer/inquiry ✔️
  • Transfer (only create and update, we can't delete) ✔️
  • Member ✔️

@enricostano enricostano merged commit f26377d into develop May 18, 2018
@enricostano enricostano deleted the feature/dashboard-events branch May 18, 2018 06:49
@enricostano enricostano mentioned this pull request Aug 8, 2018
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.

6 participants