W
W
wefhuieu2020-04-01 01:05:50
PHP
wefhuieu, 2020-04-01 01:05:50

How to determine that the time has expired?

Hello. Guys, tell me how to find out to the script that the time for checking the order has ended, and it is automatically accepted by the system, as implemented on the kwork, when the service was ordered, the person handed it over, and time is given for example 3 days for the customer to check and confirm, if the customer does not accept, the system automatically completes the order after 3 days, and sets the status completed.

It is clear that using cron is not an option, every second to hammer the script, make a bunch of queries to the database, and check each order that has a check status, and check for a time, passed or failed.

Tell me how it is implemented on kwork, I will be very grateful! Thank you)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel K, 2020-04-01
@wefhuieu

Good day.
Just through Kron the most variant.
You do not have to make a "bunch" of queries - the SQL language is quite powerful and you can select all the information of interest at once.
Once a second is not necessary. If "3 days to check", then it is enough to check once an hour, or once a day in general (depending on the accuracy you need).
I doubt that you will have such a "highly loaded" service that the processing of at least 1000 positions would take any significant time.
If, for some reason, 30 seconds are not enough to execute the script and a really "significant" load - process in portions (upload everything that needs to be processed with one request, set a flag that you do not run until the end of processing, and then process 100 pieces at a time, and then uncheck the flag), either rewrite the code in a normal way and optimize, or create a server cluster and distribute tasks, but this is a completely different story. I think the principle is clear.

T
ThunderCat, 2020-04-01
@ThunderCat

Why is it so difficult, the time of completion of the work is taken, and 3 days are considered, if 3 days have passed, then the order has been accepted. If you really want to - at the time of this check, you can put some flag in the database, but in principle it is not necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question