-
Notifications
You must be signed in to change notification settings - Fork 3
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
Open
oguzkocer
wants to merge
43
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.
Open
Caching support #976
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
096aa13
Add SQLite post mappings for wp_mobile_cache
oguzkocer a0a2750
Add unit tests for SQLite post mappings
oguzkocer 007d1df
Add Repository pattern for database operations in wp_mobile_cache
oguzkocer de670e7
Add upsert method to PostRepository for atomic insert/update operations
oguzkocer 3b406cb
Add site_id to post database structure
oguzkocer 6081f4b
Add sites table migration and foreign key constraint
oguzkocer 2bcc245
Add Repository pattern design documentation
oguzkocer d0641fc
Introduce RowId type and replace SiteId with DbSite
oguzkocer 483b318
Split QueryExecutor and TransactionManager traits for type-level tran…
oguzkocer 86b0212
Rename site_id to db_site_id for consistency
oguzkocer 4b73e8a
Document term_relationships design and add reorganization prompt
oguzkocer e0efc56
Implement term relationships normalization
oguzkocer a7d7b19
Add cache freshness tracking with last_fetched_at
oguzkocer f59ecfe
Reorganize documentation into focused topic-specific files
oguzkocer 2e3830f
Add comprehensive test suite for PostRepository
oguzkocer 25dc745
Consolidate test helpers by migrating to rstest fixtures
oguzkocer 5658bda
Increase the migration count in WordPressApiCacheTest
oguzkocer f564bb7
Consolidate post insertion logic into single upsert method
oguzkocer a6abe51
Remove InsertIntoDb trait
oguzkocer acc8285
Remove Repository trait
oguzkocer 0b6894e
Update documentation to reflect consolidated post insertion logic
oguzkocer 19dc688
Temporarily remove wp_mobile_cache documentation
oguzkocer 41ef762
Remove unnecessary comment from DbSite
oguzkocer 75ae8e9
Add From<String> and From<&str> implementations for TaxonomyType
oguzkocer 3395d21
Remove unused test helpers and redundant test
oguzkocer 88ffcfb
Refactor test infrastructure to use centralized TestContext
oguzkocer 2da33f4
Complete TestContext migration and simplify fixture structure
oguzkocer 168a309
Rename test_helpers to test_fixtures for consistency
oguzkocer 661aab6
Remove unused query methods from PostRepository
oguzkocer 8b6bcff
Remove redundant tests from posts mapping
oguzkocer 695be1d
Remove DbEntity trait and centralize table names in repositories
oguzkocer ee9edcb
Enforce transaction requirement for sync_terms_for_object
oguzkocer 8766216
Enforce term loading via type-safe PostTerms parameter
oguzkocer 55ba1a1
Refactor term loading to use generic repository pattern
oguzkocer f95d045
Fix term relationships to use WordPress object IDs instead of SQLite …
oguzkocer 8f33f0c
Enforce PostBuilder pattern and improve test ergonomics
oguzkocer 9cf8b7f
Add with_post_id() builder method for PostId convenience
oguzkocer a281955
Replace for loops with functional programming patterns
oguzkocer 351aecb
Refactor tests to use repository instances from test context
oguzkocer 777a93e
Combine duplicate round-trip tests into parameterized test
oguzkocer 5c54f9b
Improve timestamp assertion with proper date parsing
oguzkocer 3a4e862
Move mapping tests to repository module
oguzkocer 8b03f03
Add InTransaction marker trait for compile-time transaction enforcement
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.