after a little bit search in stackoverflow I came up with this query which I wanted, and its like this:
SELECT * FROM workers where TIMESTAMPDIFF(SECOND, last_activity_time, NOW()) >= (60/per_hour*60)
each record is consist of these fields:
id worker_name last_activity_time per_hour
so each worker has a per_hour field that will determined as actions number per hour.
last activity is the last time worker was doing an action. It will get records that are qualified to run at current time.
so it will determine time interval with 60/per_hour
in seconds and selects the records which time passed from their last_activity_time
till now is more than this calculated interval.
this works okay, But I want to know two things.
1: is this query a good approach for this problem or its slow?
2: how can I do this query in laravel 5.5
active records or query builder? and also it should return one record at a time.
thanks in advance