-
Notifications
You must be signed in to change notification settings - Fork 44
feat: activity notifications #31
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
Conversation
add accounts test
Send error signals when failing to link stripe accounts
format
0572de1
to
3295e78
Compare
I have also added ExCoveralls and started building out some coverage; I am hoping to have all the notifications covered as some of them are tough to exercise. I've copied some of the mocks into |
Frustratingly, it seems as though it's impossible with this setup to load the "associated" object from the Activity without adding either a Would it be possible for you guys to give me a list of "Activities" you are interested in displaying to the user? I kept this implementation very broad because it would give me flexibility while figuring that out. Now that a join table with a foreign key per association is needed, it's probably best to figure out what we want ahead of time. @zcesur you mentioned this was more granular than you would have done it; what level of granularity are you looking for? Also, it might be helpful to get me a list of all the emails that are sent from the old code base, along with their content. FYI The reason Ecto doesn't do Rails style polymorphism is because it's unable to retain referential integrity on delete when using |
drop transaction activities and 'second' level activities associated with a user
That's a bummer, this looked very promising. What kind of error/result is your union_all reducer returning? While it's all fresh in your mind, I suggest writing up a quick question about it on the Elixir Forum before ditching it - I see lots of active senior Elixir folks there including the core Ash devs In any case, the many-to-many approach should be perfectly fine! In terms of granularity we'd probably wanna track most changes on most schemas at some point to have a proper audit log, but for the time being let's focus on main business capabilities & events, starting with things like:
Let's do emails only for
|
All is not lost: I managed to get the associations loading using a virtual Thanks for the extra info! I'm starting to get the hang of this app, should be easy to get those in there. |
broadcast from Oban job enqueue email deilvery add mail templates
Amazing 🫡 |
* activities (with has_many on_replace: :ignore) * add more tables, test helpers add accounts test * add more user activity attributes * add Repo.insert_with_activity/2 * add notifier * rename * Repo.update/delete_with_activity * test register github user activities * add coveralls * add basic coverage for bounties, chat and reviews and coveralls.json * remove redundant * remove ecto fork * Setup notifier and signal module Send error signals when failing to link stripe accounts * account coverage * update coveralls * rename * fetch user activities from nested children * add notifier job template * satisfy the dialyzer format * filter out bounties without solver when onboarding dev, fix KeyError * lower Drawer z-index; it was hiding flash messages * load association for activities drop transaction activities and 'second' level activities associated with a user * use Dataloader for loading activity associations * add Mox to dev * add create_session to Stripe SeedImpl * format * use map for activity table lookups * add owned|created_tips to User * add bounty and tip activities * test * add activities dropdown in main nav and on company admin page * implement Algora.Analytics.get_company_analytics/0-2 * remove transaction activities * zero not implemented demo data * add activity redirect controller * add User#received_tips * cleanup * typo * load target association with Activities.get * show activities in header broadcast from Oban job enqueue email deilvery add mail templates * fix merge * Protocol.UndefinedError for claims when creating tips * adapt bounty testing to claims * add on true to inner_lateral_join * add redirect url to email body * remove vars from email subjects * use schema.preload/1 * add claim_submitted and bounty_awarded activities * add utility for making admins * remove unused alias * add mix algora.create_tip * send email job * rework activity views * assert mail job enqueued * add todos
This feature adds activity notifications and optional change tracking to the app. It works by creating a 'abstract'
activities
table for each table we want activities to be associated with, as described here. I have added an activity table for almost every table in the database, although some some might no make sense and can be removed later.The main entry point for adding activities is through
Algora.Repo.insert/update/delete_with_activity
. It creates anEcto.Multi
transaction for inserting associated activities and any Oban jobs. A more ergonomic option not requiring aMulti
transaction isActivity.put_activity/3
, but that requires adding a newon_remove: :ignore
option to Ecto, otherwise we will have to load all associated activities for the target object prior to updating. I have removed this fork of Ecto for now and we are still using the defaulton_remove: :raise
, as I am not not sure if they will adopt:ignore
.Querying this setup is accomplished by "unioning" all the tables that you want activities from, instead of filtering out the uninteresting
assoc_type
as you would with one giant 'activities' table. It also makes it possible to "union" across tables using associations, for example, getting all contract activities for a user. This even works with nested associations, for example getting all contract activities for a user, including associated transaction activities. Querying for all activities of one type is very simple.My plan is to have all a user's 'activities' displayed in a 'feed' somewhere, and also emailed to them if they are not online, depending on the activity.
See this graph for a basic visual description: