Draft
Conversation
Remove bucket parameter and create is_submission_ungraded() helper: Cache consistency fix: - Remove bucket="ungraded" parameter from get_submissions() calls - Always fetch all submissions and filter locally - Document why bucket parameter causes cache inconsistencies - Move submission.assignment assignment outside filter condition - Add comprehensive documentation of filtering strategy Code quality improvement: - Create is_submission_ungraded() helper function in submissions.nw - Deduplicate inline check from three locations - Update submissions.nw to use helper in list_ungraded_submissions() - Update assignments.nw to import and use helper in list_assignments() - Update results.nw to use helper instead of timestamp comparison - Fix results.nw to use grade_matches_current_submission (more accurate) Benefits: - Fixes cache inconsistency when mixing bucket/non-bucket calls - Single source of truth for ungraded logic - Eliminates code duplication across three modules - More accurate detection in results.nw (uses grade_matches vs timestamps) - Better maintainability - changes only need to happen in one place 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds opt-in bulk refresh mechanism to reduce API calls when many cached submissions are stale. Key changes: - Add logging and os imports for logging module and env var reading - Add BULK_REFRESH_THRESHOLD and BULK_REFRESH_MIN_COUNT constants configurable via environment variables (default 0.2 and 3) - Add would_need_refresh() method to LazySubmission for non-mutating staleness checks - Add check_bulk_refresh parameter to get_submissions decorator - Implement pre-check phase that counts stale submissions and triggers bulk fetch if threshold exceeded (1 API call instead of N individual) - Update wrappers in-place preserving object identity Performance improvement: 40 API calls → 1 API call for -U scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Modifies submission listing functions to enable bulk refresh optimization: - list_ungraded_submissions() always passes check_bulk_refresh=True since it accesses mutable attributes on all submissions to filter ungraded ones - list_submissions() accepts check_bulk_refresh parameter and passes it through to get_submissions() - Calling code enables bulk refresh when no user/category/group filters are applied (accesses all submissions) This reduces API calls from N to 1 when using -U flag or listing all submissions without filters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds detailed literate programming documentation explaining the threshold-based bulk refresh optimization: - Performance bottleneck: lazy loading triggers N individual API calls when accessing all submissions (e.g., -U flag with 40 stale = 40 calls) - Solution: pre-check phase counts stale submissions, triggers bulk refresh if threshold exceeded (1 API call instead of N) - When to enable: -U flag, unfiltered listings (accessing all submissions) - Threshold configuration: 20% with minimum 3, configurable via env vars - Trade-offs: dramatic speedup vs pre-check overhead - Design rationale: why decorator not wrapper, why opt-in not automatic Documentation uses variation theory: contrasts individual vs bulk refresh, explains the "whole" (problem), decomposes into "parts" (solution details), and brings back together (when/how to use). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…hacks/canvasapi.nw by keeping lazy submission caching with bulk refresh and preserving logging imports
…date references and docs
Owner
Author
|
Merged an alternative solution in master. Should probably use the idea of LazySubmission from this branch at some point in the future. |
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
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.
Supercedes #251.