-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: Caching support #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
oguzkocer
wants to merge
41
commits into
trunk
Choose a base branch
from
wp_mobile_cache-mapping
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,388
−48
Draft
WIP: Caching support #976
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
50a6753
Add SQLite post mappings for wp_mobile_cache
oguzkocer 61fc706
Add unit tests for SQLite post mappings
oguzkocer fe99eb0
Add Repository pattern for database operations in wp_mobile_cache
oguzkocer 3b73a66
Add upsert method to PostRepository for atomic insert/update operations
oguzkocer c9c28ff
Add site_id to post database structure
oguzkocer 5efdb26
Add sites table migration and foreign key constraint
oguzkocer 825481f
Add Repository pattern design documentation
oguzkocer e67b521
Introduce RowId type and replace SiteId with DbSite
oguzkocer 9e4e16b
Split QueryExecutor and TransactionManager traits for type-level tran…
oguzkocer e4737f3
Rename site_id to db_site_id for consistency
oguzkocer d637f2c
Document term_relationships design and add reorganization prompt
oguzkocer 73b416e
Implement term relationships normalization
oguzkocer e7e8415
Add cache freshness tracking with last_fetched_at
oguzkocer 1bd73c6
Reorganize documentation into focused topic-specific files
oguzkocer 2ec502a
Add comprehensive test suite for PostRepository
oguzkocer 5a93204
Consolidate test helpers by migrating to rstest fixtures
oguzkocer 932b10f
Increase the migration count in WordPressApiCacheTest
oguzkocer 56df719
Consolidate post insertion logic into single upsert method
oguzkocer 306b34b
Remove InsertIntoDb trait
oguzkocer 0074ac1
Remove Repository trait
oguzkocer 0e95f58
Update documentation to reflect consolidated post insertion logic
oguzkocer f757fd7
Temporarily remove wp_mobile_cache documentation
oguzkocer f394d19
Remove unnecessary comment from DbSite
oguzkocer 2b467cd
Add From<String> and From<&str> implementations for TaxonomyType
oguzkocer 4126780
Remove unused test helpers and redundant test
oguzkocer 84ca651
Refactor test infrastructure to use centralized TestContext
oguzkocer 5b94704
Complete TestContext migration and simplify fixture structure
oguzkocer 063d5ff
Rename test_helpers to test_fixtures for consistency
oguzkocer b07d467
Remove unused query methods from PostRepository
oguzkocer c185b06
Remove redundant tests from posts mapping
oguzkocer fe6c03e
Remove DbEntity trait and centralize table names in repositories
oguzkocer 1c1699c
Enforce transaction requirement for sync_terms_for_object
oguzkocer 130f2ac
Enforce term loading via type-safe PostTerms parameter
oguzkocer 5ef887c
Refactor term loading to use generic repository pattern
oguzkocer eeecf14
Fix term relationships to use WordPress object IDs instead of SQLite …
oguzkocer ed75851
Enforce PostBuilder pattern and improve test ergonomics
oguzkocer 0b45606
Add with_post_id() builder method for PostId convenience
oguzkocer df41e51
Replace for loops with functional programming patterns
oguzkocer af55ccf
Refactor tests to use repository instances from test context
oguzkocer 1cb3bf5
Combine duplicate round-trip tests into parameterized test
oguzkocer 5c857b3
Improve timestamp assertion with proper date parsing
oguzkocer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| CREATE TABLE `sites` ( | ||
| -- Internal DB field (auto-incrementing) | ||
| `id` INTEGER PRIMARY KEY AUTOINCREMENT | ||
| ) STRICT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| CREATE TABLE `posts_edit_context` ( | ||
| -- Internal DB field (auto-incrementing) | ||
| `rowid` INTEGER PRIMARY KEY AUTOINCREMENT, | ||
|
|
||
| -- Site identifier (foreign key to sites table) | ||
| `db_site_id` INTEGER NOT NULL REFERENCES sites(id) ON DELETE CASCADE, | ||
|
|
||
| -- Top-level non-nullable fields | ||
| `id` INTEGER NOT NULL, | ||
| `date` TEXT NOT NULL, | ||
| `date_gmt` TEXT NOT NULL, | ||
| `link` TEXT NOT NULL, | ||
| `modified` TEXT NOT NULL, | ||
| `modified_gmt` TEXT NOT NULL, | ||
| `slug` TEXT NOT NULL, | ||
| `status` TEXT NOT NULL, | ||
| `post_type` TEXT NOT NULL, | ||
| `password` TEXT NOT NULL, | ||
| `template` TEXT NOT NULL, | ||
|
|
||
| -- Top-level optional fields | ||
| `permalink_template` TEXT, | ||
| `generated_slug` TEXT, | ||
| `author` INTEGER, | ||
| `featured_media` INTEGER, | ||
| `sticky` INTEGER, | ||
| `parent` INTEGER, | ||
| `menu_order` INTEGER, | ||
|
|
||
| -- Optional enums (stored as TEXT) | ||
| `comment_status` TEXT, | ||
| `ping_status` TEXT, | ||
| `format` TEXT, | ||
|
|
||
| -- Complex optional fields (JSON) | ||
| `meta` TEXT, | ||
|
|
||
| -- Nested: guid (guid is non-optional, but guid.raw is optional) | ||
| `guid_raw` TEXT, | ||
| `guid_rendered` TEXT NOT NULL, | ||
|
|
||
| -- Nested: title (title is non-optional, but title.raw is optional) | ||
| `title_raw` TEXT, | ||
| `title_rendered` TEXT NOT NULL, | ||
|
|
||
| -- Nested: content (content is non-optional, but some fields are optional) | ||
| `content_raw` TEXT, | ||
| `content_rendered` TEXT NOT NULL, | ||
| `content_protected` INTEGER, | ||
| `content_block_version` INTEGER, | ||
|
|
||
| -- Nested: excerpt (entire struct is optional) | ||
| `excerpt_raw` TEXT, | ||
| `excerpt_rendered` TEXT, | ||
| `excerpt_protected` INTEGER, | ||
|
|
||
| -- Client-side cache metadata: when this post was last fetched from the WordPress API | ||
| `last_fetched_at` TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), | ||
|
|
||
| FOREIGN KEY (db_site_id) REFERENCES sites(id) ON DELETE CASCADE | ||
| ) STRICT; | ||
|
|
||
| CREATE UNIQUE INDEX idx_posts_edit_context_unique_db_site_id_and_id ON posts_edit_context(db_site_id, id); | ||
| CREATE INDEX idx_posts_edit_context_db_site_id ON posts_edit_context(db_site_id); | ||
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
wp_mobile_cache/migrations/0003-create-term-relationships.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| CREATE TABLE `term_relationships` ( | ||
| -- Internal DB field (auto-incrementing) | ||
| `rowid` INTEGER PRIMARY KEY AUTOINCREMENT, | ||
|
|
||
| -- Site identifier (foreign key to sites table) | ||
| `db_site_id` INTEGER NOT NULL, | ||
|
|
||
| -- Object identifier (rowid of post/page/nav_menu_item/etc) | ||
| -- Note: No FK constraint since this can reference different tables | ||
| `object_id` INTEGER NOT NULL, | ||
|
|
||
| -- WordPress term ID | ||
| `term_id` INTEGER NOT NULL, | ||
|
|
||
| -- Taxonomy type ('category', 'post_tag', or custom taxonomy) | ||
| `taxonomy_type` TEXT NOT NULL, | ||
|
|
||
| FOREIGN KEY (db_site_id) REFERENCES sites(id) ON DELETE CASCADE | ||
| ) STRICT; | ||
|
|
||
| -- Prevent duplicate associations (same object can't have same term twice in same taxonomy) | ||
| CREATE UNIQUE INDEX idx_term_relationships_unique | ||
| ON term_relationships(db_site_id, object_id, term_id, taxonomy_type); | ||
|
|
||
| -- Query: "Find all objects with taxonomy X and term Y" | ||
| CREATE INDEX idx_term_relationships_by_term | ||
| ON term_relationships(db_site_id, taxonomy_type, term_id); | ||
|
|
||
| -- Query: "Find all terms for object X" (used in joins when reading posts) | ||
| CREATE INDEX idx_term_relationships_by_object | ||
| ON term_relationships(db_site_id, object_id); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be handled in a relationship table in a subsequent PR.