def get_all_positive_customers(): """Get all positive customers Returns: json response """ pos_customers = CustomerManager.retrieve_all_positive() if pos_customers is None: response = {'status': 'No positive customers'} return jsonify(response), 404 return jsonify([customer.serialize() for customer in pos_customers]), 200
def check_customer_health_status(): logger.info('Executing the task <customer_healthcheck>') positive_users = CustomerManager.retrieve_all_positive() if positive_users is None: # skip computation return for positive_user in positive_users: time_delta = datetime.datetime.utcnow( ) - positive_user.health_status_change_datetime if time_delta >= timedelta(days=14): # unmarking positive_user.set_health_status(False) CustomerManager.update_customer(customer=positive_user) logger.info('Task <customer_healthcheck> finished')
def authority(id, positive_id): """This method allows the Health Authority to see its personal page. Args: id (int): the univocal identifier for the Health Authority positive_id (int): the identifier of the positive user Returns: Redirects to the page of the Health Authority """ if current_user.id == id: authority = AuthorityManager.retrieve_by_id(id) ha_form = AuthorityForm() pos_customers = CustomerManager.retrieve_all_positive() search_customer = CustomerManager.retrieve_by_id(positive_id) return render_template('authority_profile.html', current_user=authority, form=ha_form, pos_customers=pos_customers, search_customer=search_customer) return redirect(url_for('home.index'))