I'm finishing up my first Codeigniter app and I have a question.
Right now I have a message for new users saying something like "Hey there, welcome to the app..."
A row in the db marks when the user has clicked "Don't show me this again".
I would like to have a table called "user-notifications" that will send a notification to the user about special deals or updated info about the app.
How do I keep track of which users have marked "Don't show me this again" if I have many messages?
I would say a simple m-n relation will do the trick
User UserNotification Notifications
-------- ------------------- -----------------
id user_id id
foo notification_id message
bar read
Note the read field in the join table. I would use it as a boolean (or whatever type your DBMS has). This way, you know if the user has "clicked the message away" or not. You could also add a date so you could query for messages not older than X.
Related
I am working on agent for restaurant tables reservation, I am detecting the reservation parameters and everything fine, I need to allow the users to update any previous parameters at any page, e.g assume the user in a page called get reservation date which responsible for getting the reservation date from the user, and at the previous pages the user entered the restaurant name and reservation time,at get reservation date page the user may say: "I want to update the restaurant name" or "I want to update the reservation time" or "I want to update the reservation time and the restaurant name", How to detect multiple update cases on a single message?
I hope I could justify what I am trying to do.
I'm building a little application using Oracle Application Express Online. I'd like to send automatically email when an user inserts into the database a row.
I created an Item, called Email, in which I put the address of the user of the application:
Select User.Email from Users wher Users.Username=:APP_USER
Query works, because in the application I see right email.
Then I create a process in the way you see in the screen I'll post here. But nothing happens. Can you help me, please?
As you see, in the centre of the photo there are 2 items: one has to go into the database to store a new row, the second one is the email that is in the process. But, as I said early, nothing happens.
If you click on any attribute in APEX, and click the "Help" tab, you get some very useful information - in this case, that the field expects a substitution syntax for this scenario.
To
Enter the email recipients by specifying one or more email addresses.
For multiple email addresses, use a comma-separated list. Use
substitution syntax if you want to use a dynamic value.
Examples
john.doe#test.com, jane.doe#test.com
John Doe <john.doe#test.com>, Jane Doe <jane.doe#test.com>
&P6_TO.
I wanna code a telegram bot, so when I gonna receive messages from a user I should know about last message he/she sent to me and in which step does he/she located. So I should store sessions of the user (I understood this when I searched) but I don't know what exactly should I do?
I know I need a table in a db that stores UserId, ChatId but I don't know these:
How to make a root for steps and store them in db (I mean how do I understand where the user is located now)
What are other columns that I need to store as a session?
How many messages should I store in the database? And do I need one row for each message?
If you just have to store session in your database you don't need to store messages. Maybe you could want to store also messages but it's not necessarily related.
Let's assume you have a "preferences" menu in your bot where the user can write his input. You ask for the name, age, gender etc.
How do your know when the user writes the input of it's about the name or the gender etc?
You save sessions in your db. When the bot receives the message you check in what session the user is in to run the right function.
An easy solution could be a sql database.
The primary key column is the telegram user ID ( you additionally can add a chat id column if it's intended to work both in private and group chats) and a "session" column TEXT where you log user steps. The session column can be NULL by default. If the bot expects the gender (because the user issued /gender command) you can update the column "session" with the word "gender" so when the message arrives you know how to handle it checking the gender column of that user id and as soon as you runned the right function, you update to NULL again the column "session".
you can create a db with these columns.
UserID, ChatID, State, Name, Age, Gender ...
on each incoming update you will check if user exists on you db then check the user's State and respond appropriately and update the state at the end.
I am building a website that will notify users of certain changes to their account via a notification bar at the top of the screen (similar to the way SO notifies of new badges).
In my DB I have a table that list the events and also a flag to denote whether they have been notified of the change yet or not. The table is of the form :
UserID AccountEvent EventDescription HasBeenNotified
ABC123 1 Your price deal ends in 2 weeks FALSE
What I would like to achieve is:
Customer logs in and is shown notification (assuming one needs to
happen)
Customer clicks to acknowledge message
DB HasBeenNotified field set to TRUE (to acknowledge notification has occurred)
I have been able to achieve all this but there is a snag!
I am putting the events that need to be notified into the HttpRuntime.Cache with a 10 min expiry so I don't need to keep polling the DB.
The issue this creates for me is that a customer could potentially see multiple notifications of the same message until the cache expires, for example:
Customer logs in and app logic looks in cache and says customer ABC123 needs to be
notified of X
Customer then acknowledges message (which updates DB to set notification flag to TRUE)
Cache does not yet reflect updated DB so if customer navigates to new page the same notification message is fired (until cache expires)
As far as I know I cannot update the actual data within the Cache (can only Remove data from cache based on cache key).
Can anybody provide hints and tips of how to get around the issue of multiple notifications?
Why not burst the cache? Remove that key from the cache?
Or you can update the cache by setting it again to new HasBeenNotified value or even set it to null which you should deal with and accept as empty.
HttpRuntime.Cache["YourKey"] = "";//new object/value;
I want to record events based on on a date. I also want people to be able to search for event based on a particular date and the person who recorded the event.
For example:
Person A logs in and sees a calendar, click on a day/date and records an event for that day.
Person B logs in and sees a calendar, click on a day/date and records an event for that day.
Person C comes and does the same thing.
Note that either of these persons can record more than one event.
I want to be able record this data effectively in the database and search for these events based on a number of different criteria.
Please can someone help me with a data structure for this problem?
Person
ID
Name
PersonalEvent
ID
Person
Name
Date