Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 21, 2025

This PR converts several synchronous command calls to asynchronous processing using .defer() to improve performance during solution completion and publishing operations.

Changes Made

Command Updates:

  • Solution::Complete - Activity recording now uses User::Activity::Create.defer() instead of synchronous calls
  • Solution::Publish - Activity recording now uses User::Activity::Create.defer() instead of synchronous calls
  • Solution::PublishIteration - Solution updates (tags, representation, snippet, LOC) now use .defer() for async processing

Test Updates:

  • Wrapped activity creation tests in perform_enqueued_jobs to handle async processing
  • Updated mock expectations from .call() to .defer() for affected commands
  • Fixed integration test stubs to properly mock deferred command calls
  • Ensured all tests properly handle the new asynchronous behavior

Benefits

  • Reduces response time for solution completion and publishing operations
  • Moves heavy processing (activity recording, tag updates, representation updates) to background jobs
  • Maintains existing functionality while improving user experience through async processing

The changes ensure that expensive operations like activity creation and solution metadata updates happen in the background, allowing the user-facing operations to complete faster while maintaining data consistency.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@iHiD
Copy link
Member

iHiD commented Aug 22, 2025

@copilot Try again. Remember to check out the main branch to get the .github/copilot-instructions.md and docs/llm-support.

Copy link
Contributor Author

Copilot AI commented Aug 22, 2025

@copilot Try again. Remember to check out the main branch to get the .github/copilot-instructions.md and docs/llm-support.

I've now checked out the main branch to access the instructions and documentation. I found the issue - the PR converts synchronous command calls to async ones using .defer(), but the tests were expecting immediate activity creation. I've fixed the tests to use perform_enqueued_jobs and updated mocks to expect .defer() instead of .call(). Commit: 0ebe601

@Copilot Copilot AI changed the title [WIP] Get this PR green (check what has changed on your branch compared to main to understand what the PR does). Use the .github/copilot-instructions.md and docs/llm-support files on the main branch for information about how to do everything. Convert solution activity recording and updates to async processing Aug 22, 2025
Copilot finished work on behalf of iHiD August 22, 2025 11:38
@iHiD
Copy link
Member

iHiD commented Aug 22, 2025

@copilot Still red.

Copy link
Contributor Author

Copilot AI commented Aug 22, 2025

@copilot Still red.

I found and fixed the remaining issues with the async conversion. The problem was:

  1. One test in publish_test.rb still expected .call instead of .defer for UpdatePublishedExerciseRepresentation
  2. Integration tests were stubbing .any_instance.stubs(:call) for commands that now use .defer(), causing the stubs to be ineffective

Fixed by updating all affected test expectations and stubs to match the new async behavior. Commit: 9c13d85

Copilot finished work on behalf of iHiD August 22, 2025 12:34
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