def http_request()

in check-release-notes/main.py [0:0]


def http_request(request):
    """HTTP Cloud Function.
    Args:
        request (flask.Request): The request object.
        <https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
    Returns:
        The response text, or any set of values that can be turned into a
        Response object using `make_response`
        <https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
    """
    rss_url = "https://cloud.google.com/feeds/bigquery-release-notes.xml"
    todays_release_notes_dict = {}
    with futures.ThreadPoolExecutor() as executor:
        todays_release_notes = executor.map(get_todays_release_note, rss_urls)
    for release_note in todays_release_notes:
        if release_note:
            todays_release_notes_dict[release_note["product"]] = release_note
    new_release_notes_only = get_new_release_notes(todays_release_notes_dict)
    if new_release_notes_only:
        print(f"Found new release notes: {new_release_notes_only}")
        # Get spaces subscribed to the products with new release notes
        subscriptions_ref = firestore_client.collection("space_product_subscriptions")
        for product, release_note in new_release_notes_only.items():
            product_doc = subscriptions_ref.document(product.replace("/", "")).get()
            if product_doc.exists:
                spaces_subscribed = product_doc.to_dict().get("spaces_subscribed", [])
                for space_id in spaces_subscribed:
                    publish_to_pubsub(space_id, release_note)
        futures.wait(publish_futures, return_when=futures.ALL_COMPLETED)
    else:
        print("No new release notes")
    return ("Done", 200)