Skip to content

feat: web page revalidation#1653

Open
cka-y wants to merge 9 commits intomainfrom
feat/mdb-web-67
Open

feat: web page revalidation#1653
cka-y wants to merge 9 commits intomainfrom
feat/mdb-web-67

Conversation

@cka-y
Copy link
Copy Markdown
Contributor

@cka-y cka-y commented Apr 8, 2026

Summary:
Closes MobilityData/mobilitydatabase-web#67
This pull request introduces a new mechanism to trigger web app cache revalidation via Google Cloud Tasks whenever certain backend processes update or modify feed data. The integration ensures that the web application remains in sync with backend changes by scheduling deduplicated revalidation tasks for affected feeds.
Web app revalidation integration:

  • Added a new function create_web_revalidation_task in gcp_utils.py to enqueue deduplicated Cloud Tasks for web app cache revalidation, with error handling and logging. This function is called after feed updates in batch_process_dataset, pmtiles_builder, process_validation_report, and reverse_geolocation_processor to ensure the web app reflects backend changes promptly. [1] [2] [3] [4] [5]
  • Updated the Cloud Function tasks_executor configuration to include the WEB_APP_REVALIDATE_SECRET secret, which is used for secure revalidation requests.
  • Added comprehensive unit tests for the revalidation task creation logic in test_web_revalidation.py, covering edge cases and error handling.

Workflow and deployment updates:

  • Updated GitHub Actions workflows (api-deployer.yml, api-dev.yml, api-qa.yml, api-prod.yml) to support new inputs and secrets for web app revalidation, including passing the revalidation URL and secret from 1Password. [1] [2] [3] [4] [5] [6]

Dependency management:

  • Added google-cloud-tasks to api/requirements.txt to support the new task scheduling functionality.

Codebase imports and structure:

  • Updated imports in several modules to use the new create_web_revalidation_task function where appropriate. [1] [2] [3] [4] [5]

These changes collectively ensure that the web application cache is automatically and efficiently revalidated after backend feed updates, improving data consistency and user experience.
Summarize the changes in the pull request including how it relates to any issues (include the #number, or link them).
Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

@cka-y cka-y changed the title Feat/mdb web 67 feat: web revalidation backend logic Apr 8, 2026
@cka-y cka-y changed the title feat: web revalidation backend logic feat: web page revalidation Apr 8, 2026
@cka-y cka-y marked this pull request as ready for review April 8, 2026 17:47
try:
response = requests.post(
revalidate_url,
json={"feedId": feed_stable_id},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the body is

{
type: 'specific-feeds'
feedIds: [feed_stable_id]
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The API didnt return any error tho

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the revalidate endpoint the default values are set to

type: 'specific-feeds',
feedIds: [],

so it wont fail if you input the wrong body. Would it be a good practice to return an error of "missing param"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at least type should be required! A readme would be nice (suggestion 😄)

Copy link
Copy Markdown
Contributor

@Alessandro100 Alessandro100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize revalidate of feed detail pages

2 participants