I have a system that will allow users to send messages to thier clients. I want to limit the user to x amount of messages per day/week/month (depending on subscription). What is a good way to tally for the time period and reset the tally once the time period restarts? I would like to incorporate some sort of SQL job to reset the tally.
Share
Each time you send a set of messages, log the date and the number of messages sent. Your application can then sum the message count fields, grouping by either the day, the week of year, or the year of the date to enforce limits. The where clause used to limit the user to a specific number would use a message limit, start date, and stop date from the user profile table, or some global settings table.
In MySql dialect, you would write something like this: