Skip to content

Remove unused server_timestamp() from IDatabase#29

Merged
mkonopelski-gd merged 1 commit into
mainfrom
chore/remove-unused-server-timestamp
Jul 7, 2026
Merged

Remove unused server_timestamp() from IDatabase#29
mkonopelski-gd merged 1 commit into
mainfrom
chore/remove-unused-server-timestamp

Conversation

@mkonopelski-gd

Copy link
Copy Markdown
Contributor

What

Removes the dead IDatabase.server_timestamp() API surface across the DB layer.

Why

server_timestamp() returned a sentinel that write paths could drop into a field to mean "server stamps now-UTC at write." It is dead: nothing in the app calls it. The only references were docstring Example: blocks (interface.py, dependencies.py) and the database test suite — no executing caller. Code that stores timestamps passes real datetime objects, which every backend already normalizes. So the sentinel path is unused (EAFP/YAGNI).

Verified before removing:

grep -rn "server_timestamp" backend --include="*.py" | grep -v "app/database/" | grep -v "/test"
# (empty)

Changes

  • app/database/interface.py — delete the server_timestamp abstractmethod; scrub stale Example: lines referencing it.
  • app/database/firestore.py — delete the SERVER_TIMESTAMP impl (kept the firestore import; still used elsewhere).
  • app/database/memory.py — delete the method, the _ServerTimestamp sentinel class, and the dead isinstance(value, _ServerTimestamp) branches in both _process_timestamps helpers (real datetime passthrough intact); drop the now-unused datetime/UTC import.
  • app/database/dependencies.py — fix the get_db docstring example to a plain datetime.now(UTC).
  • test/database/test_memory_db.py, test/database/test_firestore_db.py — delete the TestServerTimestamp classes and now-unused datetime imports.

Verification

  • uv run pytest test/database/ -q45 passed, 15 skipped (firestore emulator skipped).
  • Imports clean: uv run python -c "import app.database.interface, app.database.memory, app.database.firestore".
  • Final grep for server_timestamp / _ServerTimestamp under backend/no matches.

Merge sequencing

The SQLite feature branch (feature/use-sqllite-instead-firestore, PR #13) carries a mirror _ServerTimestamp that will be dropped when that branch rebases onto this change. Please merge this PR first, then rebase PR #13.

…atabase

`IDatabase.server_timestamp()` is dead API — nothing in the app called it.
The only references were docstring `Example:` blocks and the database test
suite; no executing caller. Write paths that store timestamps pass real
`datetime` objects, which every backend already normalizes, so the sentinel
path was unused (EAFP/YAGNI).

Removed: the abstractmethod (interface.py), the Firestore SERVER_TIMESTAMP
impl (firestore.py), the InMemory method + `_ServerTimestamp` sentinel class
+ its `isinstance` branches in the encode/normalize helpers (memory.py), the
stale docstring examples (interface.py, dependencies.py), and the
server_timestamp tests (test_memory_db.py, test_firestore_db.py).

Note: the SQLite feature branch (feature/use-sqllite-instead-firestore,
PR #13) carries a mirror `_ServerTimestamp` that will be dropped when that
branch rebases onto this change — reviewers should merge this PR first.
@mkonopelski-gd mkonopelski-gd merged commit d447603 into main Jul 7, 2026
3 checks passed
@mkonopelski-gd mkonopelski-gd deleted the chore/remove-unused-server-timestamp branch July 7, 2026 15:32
mkonopelski-gd added a commit that referenced this pull request Jul 7, 2026
Integrates PR #29 (removal of the unused server_timestamp() API). Drops this
branch's now-orphaned mirror copies of that dead code:
- sqlite.py: _ServerTimestamp sentinel, its _encode_for_storage branch, and
  SqliteDatabase.server_timestamp()
- db_contract.py: the shared TestServerTimestamp contract test (+ now-unused
  datetime import)
- test_sqlite_db.py / test_memory_db.py: the TestServerTimestamp inheritors

Conflict in test_memory_db.py resolved in favor of this branch's
inherit-from-db_contract structure, minus the removed server_timestamp test.
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.

2 participants