def get_certificates_for_expiration_metrics(expiry_window):
    """

    :param expiry_window: defines the window for cert filter, ex: 90 will only return certs expiring in the next 90 days.
    :return: list of certificates
    """
    filters = [
        Certificate.expired == false(),
        Certificate.revoked == false(),
        not_(Certificate.replaced.any())
    ]

    # if expiry_window param was passed in then get only certs within that window
    if expiry_window:
        filters.append(Certificate.not_after <= arrow.now().shift(days=expiry_window).format("YYYY-MM-DD"))

    return database.db.session.query(Certificate).filter(*filters)


    :param expiry_window: defines the window for cert filter, ex: 90 will only return certs expiring in the next 90 days.
    :return: list of certificates
    
lemur/certificates/service.py