def run_lookup(self, files=None): """ Create a new sqlite db filled with a lookup table, useful for client applications to not overload the API server and to provide a better UX. """ task = LookupTableTask() task.perform_update()
def api_get_lookup_table(): """ <h3>/client-lookup-table/?local_update=date</h3> <p>Rooms lookup table</p> <p><em>date[string]</em> : a date with format yyy/mm/dd</p> <p>Return an object with a boolean <em>update</em> attribute and the URL of the sqlite database.</p> <p>If the <em>update</em> attribute is true, the client should update its local db.</p> """ date = request.args.get('local_update') or "" print(date) try: date_obj = datetime.strptime(date,"%Y/%m/%d") except ValueError: abort(400) task = LookupTableTask() to_update = task.client_should_update_db(date_obj.timestamp()) return jsonify({ 'update': to_update , 'url':lookup_table_url(task.db_name()) })
def setUp(self): self.ltt = LookupTableTask()