Forums

update table info based on time

hi,

I am trying to create a site where jobs get posted. Suppose a job post is like starting in Feb 5, 9am. When a user views the page /all_jobs which displays all jobs list, how do I not show the jobs which are past that time?

  1. Is it better to check the time when user visits mysite.com/all_jobs when viewing and then compare that with the posted time and not show it ?
  2. Is it better to run a background job to frequently check database and check the time and update the status of the job?
  3. Is it better to add some callback function like below? Can this be done in Flask?
@app.route('/all_jobs') 
@run_my_fun 
@login_required 
def all_jobs():
    return #query db and show jobs

I don't fully understand your problem statement, but solution 1 seems the best. It appears to be a 'display filter' situation - no need to change the data in the db?

Jim

Thanks for the reply @jgmdavies , how do I handle this in Flask?

Sorry, I haven't used Flask.

It sounds to me that you need a view which includes a filter based on 'current time', i.e. you use a query which only retrieves the records you want, based on their 'start' times and the current time.

Anyone else?

Jim