I'm building an auction site in Spring and Postgres where the user can list his product and other user can bid and buy (like ebay).
What I want to do is when some auction ends the system send and email to the user saying to check the page and pay. These dates are stored in the auction table and can be any date (the end date is the starting date + 30 days).
Someone knows how can I send an email on this dates (the best way to do without overload the system!)?
thanks
You can execute some job on some interval, lets say every day. In this job you query the table from the database and chek if you have to send mails for some auction.
I don't know if is the most correct way, but I follow https://stackoverflow.com/a/18896316/3237975 and everything worked as I wanted.
I just change a little bit the class CustomTask to accept an input date and done!!
Thanks for the help
(if this approach is not the best performance wise, please advice other better)
Related
I am working on a bus booking project,
I don't know to apply this date shifting.
My requirement is that
If today people booked 25 tickets out of 30. so the next day all seats should be empty.
There are many ways to implement this use case. I prefer this one, create a domain that has a field of date, a field of maxSeat, and it can hold a list of userIds. So every day when someone requests for taking a seat, you can retrieve data by date, and if there is no instance for that particular date you can create one, and put that user's id into the userIdList, with that manner you can modify your maxSeat and if you'll need any other extra field or operation, you can handle them.
Feel free to ask any questions.
I'm absolute noob in Java and Mysql. Have an assignment to make where user need to login and register. All code been done. But there is one little part where the user's login should expire in 6 month. I'm trying to accomplish it by using SELECT DATEDIFF(month,'2014-06-05','2014-08-05') AS DiffDate. I can track user's registry date but with the second date I'm a bit stumped. How can I track the current time of user login. Any suggestions. Thank you.
You can use MySQL NOW() :
SELECT DATEDIFF(month,'2014-06-05',NOW()) AS DiffDate
I am planning on creating a small website with JavaEE where a user can vote but only every 5 minutes. There are two buttons. One to vote yes and the other to vote no. I want the buttons to only be clickable every 5 minutes. Whats the best way to do this?
I thought of getting the users IP and entering it into my DB along with the timestamp. Everytime a user would vote I would get their IP from the DB and check if 5 mins have passed since their last vote. What do you think of this solution? Is this best practise?
I am trying to avoid a login or any other sort of authentication.
I plan on using JSF, Java, mySQL and AJAX.
One possible solution could be a cookie containing the last date of vote in client side plus saving the user IP and date of vote in a datatabse in server side.
If there is no cookie in client side and if there is zero entry in your database containing the user's IP address, or if the date stored in this enty is inferior to your vote recover time, then the user can vote.
Keep in mind that the more people will click your buttons, the more request your server will have to handle.
There is no risk zero, but you can get close to it.
I am trying to figure out how I can pull records from a mongo database using Jongo that will check the date that is on the object in the db and will only return an object with the data from, in my case, the last three most current dates. I'm using LocalDate to set the date on the object.
So that's the problem, what I'm doing is I have an angularjs web ui that interfaces with a java backend and I'm trying to scale down my scope, because the current way I'm displaying data is not feasibly scalable. So I want to limit the response I receive to the last 3 objects created instead of all of the objects. And I'm to the point where I need to do a check on the date but I can't seem to find a reasonable solution. isAfter() and isBefore() was where I started my initial effort, but I can't guarantee the dates in any way so I don't know where to set my constraints.
The code I'm working on doesn't really matter, I'm just more interested in how I can do the check in general.
Thanks in advance for any help, if any at all, can be offered!
I will try to explain what I want to do.
I have a table in which I store the time that a user enters to work and update this row when the user leaves his work. The fields are timeIn and timeOut.
Before I store the timeOut, I want to display how many hours the user has worked so far. So I think I have to retrieve the timeIn and calculate the difference with the actual hour of the system. But I don't know how to retrieve only one field of a table. I reckon I have to create an object time(for example) and get the timeIn along with other parameters and then calculate the difference. But I don't know whether I'm right and how to do that.
Cheers
See here: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timediff
You may be able to get the hours worked straight from MySQL thusly:
SELECT TIMEDIFF(NOW(), timeIn) AS hoursWorked
FROM yerTable
WHERE personIdOrWhatever...
You didn't tell us what type of field timeIn is. It should be datetime.