I'm extending an existing Django forum app (DjangoBB) to allow users to opt in/out of notifications for specific forums and/or specific threads. I already have an existing notification infrastructure on my site, and an existing global setting to turn forum notifications on/off.
What I want to do is allow each user to subscribe/unsubscribe from specific forums or threads, effectively overriding their global setting. For example, if my global setting is 'Notifications Off', then I would not get any notifications, unless I set a specific forum to 'Notifications On', in which case I'll get notifications for everything in that forum, unless I set a thread in that forum to 'Notifications Off'. If any thread or topic doesn't have a setting set, it defaults up the chain.
My question is what's the best way to represent all of this in my database in Django? I have two ideas:
class ForumNotificationSetting(models.Model):
user = models.ForeignKey(User)
forum = models.ForeignKey(Forum)
setting = models.NullBooleanField(default=None)
I would also have a similar model for TopicNotificationSetting. This way, whenever a user changes their forum settings, I create (or modify) a NotificationSetting object to reflect their new settings. This method seems simple, but the downside is if lots of people create settings for lots of forums, then creating notifications for everyone would be O(n^2) whenever a new forum post is made. (I think...?)
The second way I can think of would be to create a ManyToMany field in each user's profile for all forums to which they have set settings for. This way seems more complicated (since I'd have to have 4 total M2M fields for 'forums on', 'forums off', 'topics on', and 'topics off'), and I'm not sure if there would be any performance benefits or not.
How would you solve this problem?
Perhaps you could create an M2M relationship on the level of the Thread or Forum object, e.g.:
class Thread(models.Model):
subscribers = models.ManyToManyField(User)
other attributes...
Then, as a user (un)subscribes from a Thread, you add or delete them from the Thread object's subscribers property.
In your application logic, when a user creates a post, thread or forum, you could just check their overall notification setting and - if set to True - add them to to the subscribers property of the newly created Thread, Post or Forum.
Each time a thread, post or forum is updated, you could then notify all subscribers.
I'd assume you'd need some logic to handle escalation (I can't find the proper word, sorry), i.e. I'd assume a notification for a Thread update should also trigger a notification for a Forum update (or should it?). And then you should of course take care that a user doesn't get spammed with post, thread and forum notifications for a single Post update...
Related
I create topic.
Attach push-subscription with target to my server.
Set the email mybusiness-api-pubsub#system.gserviceaccount.com as an administrator.
Update notification settings with valid topic name and next notificationTypes:
GOOGLE_UPDATE
NEW_REVIEW
UPDATED_REVIEW
NEW_QUESTION
UPDATED_QUESTION
NEW_ANSWER
UPDATED_ANSWER
Did a test by manually posting a message and got the webhook successfully.
But, when I edit review reply - I recive part of events and with delay up to 30 minutes. Part of notifications don't receive.
If I try to write question or answer - I don't receive any events.
Question:
why events do not come for questions
why events are delayed
how to fix the previous two points
Concerning NEW_QUESTION, UPDATED_QUESTION, NEW_ANSWER, UPDATED_ANSWER, this is a bug (more see here Google My Business push notification is not sent for Question and Answers ).
Concerning review updates, we are also seeing such delays. My guess is this is due to Google's publishing/QA pipeline where changes are first checked if they meet the guidelines before they are published globally. You yourself may see your changes right after editing, but that does not mean that the whole world will.
There's nothing you can do about either case, unfortunately.
We are developing a TODO list kind of application in WPF
1)when user logs in we load list of workitem for the user(only basic details)
2)when user opens particular workitem we load all its information from service
3)we use signalr to add new workitem to the user when he is working on the system (singalr will
send the workitemid, and based on it we will fetch basic detail and add it to the workitem list)
Whenever user edits the workitem, if he changes anything in the workitem information, we should move it to UnSaved List, and if he reverts it we need to move the workitem to Opened List
1)when user enters something in screen it directly alters model (letsay workitem model has user model and user model has firstname, this firstname is bound to the textbox), how to communicate this change
to the viewmodel, so that viewmodel will move this workitem to unsaved list.
To find out a workitem is dirty or not, we are keeping Unchanged workitem details inside each workitem, so whenever user changes something in screen we make comparision with this unchanged workitem and move it to unsave or opened list.
2)Is it right approach to have Unchanged workitem inside each workitem, are there any best approach or pattern available?
3)how to differentiate between user changing some value of workitem and system changing values of workitem
let say A and B user sees the same workitem in edit mode, User A edits some value in workitem and
saves it, now user B will receive this information through signalr notification, and we will make a call to service based on this workitemid and will populate the changes in B's screen. Now we should not move the workitem to unsaved list, because changes are done by system.
4)Moreover we will recieve lot of signalr notification related to multiple workitems, we don't
want to make multiple service call as and when signalr notification comes, but whenever user clicks on workitem we would like to see the changes done in that workitem from other user. What is the efficient way of doing this. (We don't want notification to contain all the information, we kept only the Id and type of the notification, so that signalr will be as lean as possible)
5)how to compensate for singalr notification failiures, (we could make some kind of timer which will periodically poll list of notifications based on the last arrived notificationid).
Is this a good approach or any pattern exist for this kind of problems.
I am not quite sure if I understand your questions.
So conceptionaly I think you are thinking about a real-time collaboration sort of software.
There are patterns and algorithm how this is solved in a distributed fashion. You should look for the papers of the google wave protocol (the foundation of the real time editing feature of the google docs tools) http://www.waveprotocol.org/whitepapers. Or research for Operational Transformation: https://operational-transformation.github.io/.
The good think is that there are already libraries out there which handle protocols like this and adapt or extend these concepts.
But finding the right library for handling realtime callobrative work over signalrs whould be a huge win. Don't know if there is also a library that builds on top of signalrs - might be worth a google or bing session.
But I think before you talk about technical details as c# or mvvm it would be a good start to understand the background of real time collaborative communication in distributed systems.
Like I said I hope I got your question correct and since you did not post any source code there is no chance to be more precise...
HTH and leads you into the right direction.
Basic question here related to Segment analytics. Unfortunately I haven't been able to find a good answer after a fair bit of searching so turning here.
I have a couple of analytics events that need to be logged against multiple users, e.g. "Matched"
Is there a way to override the "userId" property on a event without calling identify again (which would override the user for all future events & thus risks race conditions or blocking on analytics)?
This is not possible with analytics.js. If you need to send events for another userId than the one you had called .identify() with, you should use a server side library to send that event.
All server side libraries will need a userId defined so it would be a good place to send that particular event.
Also Segment just got a brand new community to post these questions fyi.
When I try to create some entities I don't see the option to input fields. I just see the SaveEntity button.
However I can view all the existing entities.
What is very strange is - there is another entity called VideoEntity for which the create did not work yesterday but works today.
Can somebody help me with this seemingly unpredictable tool ?
Regards,
Sathya
i think the console knows what properties each entity has based on existing data, rather then your models. and the data is only updated periodically. when did you upload your app? maybe waiting a few hours will give the console time to update.
alternatively, you could use the remote api to add your entities, or write a small snippet and upload such as ...
VideoStatsEntity(app='home', ip='116.89.52.67', params='tag=20130210').put()
Writing a simple interface to the data-store to allow you to edit/create models is probably the best thing to do in this case. You know what they contain so you can adjust your interface accordingly, rather then waiting for the admin interface to "catch up" as Gwyn notes.
I believe that there are some property types that are impossible to add via the admin interface that you are using so you'll probably get to the point sooner rather then later of creating a custom interface.
The admin datastore view is good for quickly checking out the contents of the datastore, but ever tried paging through 100's of entries? Not fun.
I’m working on a multi-user winforms application (MDI). Our application uses NHibernate and one session per instance.
The problem is if an user makes modification, for example a user adds an item to a list, another user doesn’t see this modification immediately. How do I get around this, what is the recommended approach? Should I be using One-session-per-form or something else?
Every application needs to define it's own unit of work. For your use case, if you are wanting the database to update every time a user adds an item to a list, then that should be your unit of work.
So to answer your question for your unique use case, I would create a new NHibernate session, persist the users changes, and dispose of the session every time a user adds an item to the list.
FYI: You should not feel that there is anything wrong with creating a session per user action if that is indeed the behavior your application desires. Typically in a WinForms application, most people do use a Session-per-Form pattern but then again, that is because most WinForms applications fall into the model of having a form that the user needs to complete before proceeding to the next form. In those cases, you would only want to persist/save the user's changes when they submit the form. But if you application does not fall into that model, then your definition of a unit of work ( session life-cycle ) could be completely different.