Skip to content

Add a per-request action log and surface failed approvals to staff - #636

Open
superconductor-for-github[bot] wants to merge 1 commit into
mainfrom
cycomachead/301-request-action-log
Open

superconductor-for-github[bot] wants to merge 1 commit into
mainfrom
cycomachead/301-request-action-log

Conversation

@superconductor-for-github

Copy link
Copy Markdown

Part 3 of 3 split out of #633. Independent of the other two parts: it branches from main and can merge in any order.

General Info

  • Breaking?

Changes

Adds requests.action_log, a jsonb array of entries (action, time, actor, message) managed by Request::ActionLog.

What gets logged

  • Approving, denying, and canceling a request. A student withdrawing their own request is logged as "Canceled".
  • A failed approval: the request is left untouched and the LMS's error is logged. This includes the case where the staff member's LMS access cannot be used at all (e.g. no Canvas token), which now goes through the normal "Failed to approve" path instead of the generic LMS error handler.
  • Auto-approval: when a course auto-approves and a request stays pending, the log says why (too many days, limit used up, too close to the deadline, not enrolled, or no working staff Canvas access). A course with auto-approval turned off logs nothing.

How staff see it

  • Request page: an "Action Log" card with the full history, plus an alert while the latest attempt is an unresolved failure.
  • Requests table: a warning badge next to the status with the reason on hover. It appears immediately when a single or batch approval fails.
  • Pending-requests digest email: failed requests are called out with the reason.

Students never see the log.

Notes for review

  • Denying has no external step, so it is recorded immediately. Revoking an LMS extension when denying an approved request is not part of this PR.
  • Request submission and student edits are not logged.
  • Request#approve now returns false (and logs) if the LMS call succeeded but the request could not be saved; it used to return true with the status silently unchanged.

Merge note: this PR and the last_action_at PR each add a migration, so whichever merges second will conflict in db/schema.rb (the version line and the new column). Re-running bin/rails db:migrate resolves it. No other files conflict.

Screenshots

Taken on the combined change in #633, so the timestamps shown also reflect the last_action_at PR.

Testing

  • RSpec: 913 examples, 0 failures. RuboCop clean.
  • All three parts merged together: 923 examples, 0 failures.
  • On the combined change, manually verified in a browser that a failed Canvas approval leaves the request pending, logs the failure, and flags the row without a reload.

Documentation

None needed.

Checklist

  • Name of branch corresponds to story

🤖 Generated with Claude Code

Adds requests.action_log, a jsonb array of entries (action, time, actor,
message) managed by Request::ActionLog.

- Approving, denying, and canceling a request each append an entry.
- A failed approval leaves the request untouched and logs the LMS's error,
  including when the staff member's LMS access cannot be used at all.
- When a course auto-approves and a request stays pending, the log says
  which rule it fell outside of, or that no staff Canvas access worked.

Course staff see the log on the request page, with an alert while the latest
attempt is an unresolved failure. Failed requests are also flagged in the
requests table (immediately, for single and batch approvals) and in the
pending-requests digest email. Students never see the log.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant