-
Notifications
You must be signed in to change notification settings - Fork 3
Add post deletion support to service layer with enhanced stress testing #1033
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
Merged
oguzkocer
merged 7 commits into
trunk
from
feature/add-post-delete-support-to-service-layer
Dec 9, 2025
Merged
Add post deletion support to service layer with enhanced stress testing #1033
oguzkocer
merged 7 commits into
trunk
from
feature/add-post-delete-support-to-service-layer
Dec 9, 2025
Conversation
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
jkmassel
approved these changes
Dec 4, 2025
da9fdc3 to
28384f3
Compare
f71bb1b to
b6f3834
Compare
Base automatically changed from
refactor/wp-mobile-crates-use-i64-instead-of-u64
to
trunk
December 9, 2025 16:43
…ost_id` Improved post deletion in the repository layer with better performance and support for entity-based deletion. Changes: - Add `delete_by_entity_id` method that accepts an `EntityId` parameter - Optimize `delete_by_post_id` to remove wasteful full post SELECT query - `delete_by_entity_id` performs lightweight SELECT for just the post ID, then delegates to `delete_by_post_id` - All deletion logic now centralized in `delete_by_post_id` - Add unit tests: `test_repository_delete_by_entity_id` and `test_delete_by_entity_id_deletes_terms` in main test module - Add constraint test: `test_delete_by_entity_id_non_existent_returns_zero` in posts_constraint_tests.rs - Both methods automatically clean up associated term relationships
Expose post deletion functionality in the service layer for both entity-based and post ID-based deletion. Changes: - Add `delete_by_entity_id` method to `PostService` - Add `delete_by_post_id` method to `PostService` - Both methods return `u64` for uniffi compatibility (converts from repository `usize`) - Both methods automatically clean up associated term relationships via repository layer - Add comprehensive unit tests: `test_delete_by_entity_id`, `test_delete_by_post_id`, `test_delete_by_entity_id_non_existent_returns_zero`, and `test_delete_by_post_id_non_existent_returns_zero` - Tests follow consistent pattern: setup via repository/helpers, actions via service layer, verification via repository
Enhanced `start_comprehensive_stress_test` to support random updates, deletes, and inserts with configurable operation weights. Refactored for better maintainability and eliminated unnecessary mutations. Changes: - Add `StressTestConfig` struct to reduce function parameters from 9 to 3 - Add `StressTestOperation` enum for type-safe operation selection (Update, Delete, Insert) - Add weighted random operation selection based on configurable weights - Extract helper functions: `stress_test_batch_update`, `stress_test_batch_delete`, `stress_test_batch_insert` - Refactor `create_test_post` to accept all parameters (title, slug, link, content) - Remove `create_temp_post` method in favor of standalone `create_test_post` - Eliminate mutations when creating new posts (all parameters passed during construction) - Convert imperative for loops to functional style using `.iter().for_each()` - Optimize counter increments to batch-level instead of per-item
Track and display individual operation counts (updates, inserts, deletes) in the stress test UI for better observability. Changes: - Add `insert_counter` and `delete_counter` to `StressTestHandle` in Rust - Add `insert_count()` and `delete_count()` methods to expose counters - Update stress test to increment appropriate counter for each operation type - Add `totalInserts` and `totalDeletes` StateFlows in Kotlin ViewModel - Add coroutine to poll operation counters every 100ms from handle - Update UI to display: "Updates: X | Inserts: Y | Deletes: Z" - Add "Total Operations" line showing sum of all operations
Add status randomization to batch updates, cycling through Draft, Pending, Publish, and Future statuses to better simulate real-world database changes.
1927b66 to
d262ff6
Compare
Update Swift example app and tests to pass a StressTestConfig struct instead of individual parameters to startComprehensiveStressTest.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Adds post deletion functionality throughout the stack (repository → service → stress test) with optimized database queries and comprehensive observability.
Changes
Repository Layer
delete_by_entity_idmethod that performs lightweight SELECT for post ID then delegates deletiondelete_by_post_idby removing wasteful full post SELECT (0 queries when deleting by post ID)delete_by_post_idfor consistencyService Layer
delete_by_entity_idanddelete_by_post_idmethods inPostServiceu64instead ofusizefor uniffi compatibilityStress Test Enhancements
start_comprehensive_stress_testto support updates, deletes, and inserts with configurable operation weightsStressTestConfigstruct to reduce function parameters from 9 to 3StressTestOperationenum for type-safe operation selection.iter().for_each())insert_counter,delete_counter) toStressTestHandlefor observabilityKotlin Example App