Beispiel #1
0
def list_active_customers():
    """
    This function returns an integer with the number of customers whose status is currently active.
    """
    db_customers = Customers.select()

    return sum([int(x.status) for x in db_customers])
Beispiel #2
0
def list_active_emails():
    """
    This function returns a list of emails of only active customers in the database
    """
    db_customers = Customers.select().where(Customers.status)
    LOGGER.debug("Returning list of active customer emails")
    email_list = [x.email_address for x in db_customers]
    LOGGER.info("Email list: %s", email_list)
    return email_list
Beispiel #3
0
def list_active_customers():
    """
    This function returns an integer with the number of customers whose status is currently active.
    """
    db_customers = Customers.select()
    LOGGER.debug("Calculating number of active customers")
    # Technically used this in Lesson 03, but it is a comprehension.  Another method added below.
    number_active = sum([int(x.status) for x in db_customers])
    LOGGER.info("There are %d active customers", number_active)

    return number_active