Skip to content

Feature: Add utility function for generating comment line for approvals #105

@zache-fi

Description

@zache-fi

Implement a function that determines the highest revision ID that can be safely approved from autorevew results, and creates a consolidated approval comment summarizing the reasons for all intermediate approvals.

Background

Currently, run_autoreview_for_page() processes all pending revisions of an article and returns approval decisions with reasons. To minimize the number of approval actions, we should approve only the latest eligible revision with a comprehensive comment explaining why all intermediate revisions were also approved.

Requirements

Input

  • Results from run_autoreview_for_page() containing approval decisions for each pending revision, with reasons such as:
    • User was a bot
    • No content change in last article
    • User was auto-reviewed
    • ORES scores (goodfaith/damaging thresholds met)
    • Other approval criteria

Processing Logic

  1. Parse through all approved revisions from the results
  2. Identify the maximum (latest) revision ID that can be approved
  3. Collect and consolidate approval reasons for all revisions up to and including the maximum revision
  4. Generate a single summary comment that lists all revisions and their approval reasons

Output

  • rev_id = highest approved revision ID
  • comment = consolidated summary of all approvals

Example Output Format

rev_id 12345 approved because user was bot, rev_id 12346 approved because no content was in last article, rev_id 12347, 12348 approved because user was autoreviewed and rev_id 12349 approved by ORES score goodfaith=0.53, damaging: 0.251.

Implementation Notes

  • Group consecutive revisions with identical reasons to keep the comment concise (e.g., "rev_id 12347, 12348 approved because...")
  • Ensure the comment clearly attributes each revision or group of revisions to their specific approval reason
  • Handle edge cases where no revisions are approved or only one revision is approved
  • Consider character limits for the approval comment field

Benefits

  • Reduces the number of approval actions needed
  • Provides transparency by documenting all approval decisions in a single place
  • Creates a clear audit trail for why multiple revisions were approved together

Acceptance Criteria

  • Function correctly identifies the maximum approvable revision ID
  • All intermediate approved revisions are included in the summary comment
  • Comment format is clear, readable, and follows the specified structure
  • Consecutive revisions with the same reason are grouped together
  • Single call to approve_revision() is made with correct parameters
  • Edge cases (no approvals, single approval) are handled gracefully
  • Unit tests cover various scenarios and approval reason combinations

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions