Fix redirect correctness and analytics tracking - #48
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e5655f401
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| nullable=False, | ||
| ) | ||
| expires_at = Column(DateTime, nullable=True) | ||
| expires_at = Column(DateTime, nullable=True, index=True) |
There was a problem hiding this comment.
Add the missing Alembic migration for the new index
This model-only index does not get applied to existing Alembic-managed databases: I checked migrations/versions and the only links.expires_at definition is in 0001_initial_schema.py, which creates the column without an ix_links_expires_at index, and there is no later migration for it. In deployments that use alembic upgrade, the database schema will drift from the model and expiration-related queries/maintenance will still lack the intended index; please add a migration that creates/drops the links.expires_at index.
Useful? React with 👍 / 👎.
Motivation
expires_atso expiration checks are reliable during redirect handling.Description
_get_redirectable_link,_enforce_click_limit, and_record_clickinapp/api/v1/redirect.py.expires_atandis_activebefore recording analytics and enforce free-tier click limits prior to writes.301to a temporary302viaREDIRECT_STATUS_CODEto avoid cache bypassing analytics.expires_atwhen creating links inapp/api/v1/links.pyand add an index onexpires_atinapp/models/link.py.tests/test_redirect.pywith coverage for analytics insertion, temporary redirect status, free click limit blocking, inactive links, and expired links.Testing
pytest -qand all tests passed.flake8on modified files and there were no lint failures.git diff --checkproduced no whitespace/errors related issues.Codex Task