Making WordPress.org

Changeset 12959


Ignore:
Timestamp:
10/31/2023 08:16:50 PM (6 months ago)
Author:
coffee2code
Message:

Photo Directory, Moderation: Improve flagging of high rejection users.

  • Reword flag text to better reflect that it's based on a percentage of rejections against total submissions
  • Increase flagging thresholds to 0.15 and 0.3 for warnings and alerts, respectively
  • Add new critical threshold of 0.5
  • Change how the rejection percentage is calculated
  • Add new "More rejections than approvals" flag
  • Change colors used for 'likely' and 'possible' flags

Fixes #7335.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/css/admin.css

    r12957 r12959  
    1919    margin-right: 4px;
    2020}
    21 .photos-flagged li.very_likely,
    22 .photos-flagged li.likely {
     21.photos-flagged li.very_likely {
    2322    background-color: #AA0000;
    2423}
     24.photos-flagged li.likely {
     25    background-color: darkorange;
     26}
    2527.photos-flagged li.possible {
    26     background-color: darkorange;
     28    background-color: goldenrod;
    2729}
    2830
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/moderation.php

    r12869 r12959  
    2222    /**
    2323     * The threshold percentage of the number of rejections relative to the
    24      * number of approvals at which the user should be flagged as a warning
    25      * (in orange). Should be a lower value than
     24     * number of approvals+rejections at which the user should be flagged as a warning
     25     * (in yellow). Should be a lower value than
    2626     * `FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE`.
    2727     *
    2828     * @var float
    2929     */
    30     const FLAG_REJECTION_WARNING_THRESHOLD_PERCENTAGE = 0.1;
     30    const FLAG_REJECTION_WARNING_THRESHOLD_PERCENTAGE = 0.15;
    3131
    3232    /**
    3333     * The threshold percentage of the number of rejections relative to the
    34      * number of approvals at which the user should be flagged as an alert
     34     * number of approvals+rejections at which the user should be flagged as an alert
    3535     * (in red) rather than a warning (in orange). Should be a higher value than
    3636     * `FLAG_REJECTION_WARNING_THRESHOLD_PERCENTAGE`.
     
    3838     * @var float
    3939     */
    40     const FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE = 0.25;
     40    const FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE = 0.30;
     41
     42    /**
     43     * The threshold percentage of the number of rejections relative to the
     44     * number of approvals+rejections at which the user should be flagged as
     45     * critical rather than an alert. Should be a higher value than
     46     * `FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE`.
     47     *
     48     * @var float
     49     */
     50    const FLAG_REJECTION_CRITICAL_THRESHOLD_PERCENTAGE = 0.50;
    4151
    4252    /**
     
    619629
    620630            if ( $rejections_count > 0 ) {
    621                 $rejections_level = '';
     631                $rejections_level = $message = '';
     632
     633                $rejections_percentage = $rejections_count / ( $rejections_count + $published_photos_count );
    622634
    623635                // A user with more rejections than approvals should be an alert.
    624                 if ( $rejections_count >= $published_photos_count ) {
     636                if ( $rejections_count > $published_photos_count ) {
    625637                    $rejections_level = 'very_likely';
     638                    $message = __( 'more rejections than approvals', 'wporg-photos' );
    626639                }
    627640                // Specify as alert or warning based on count relative to alert threshold.
    628641                else {
    629                     $reject_pct = $rejections_count / $published_photos_count;
    630                     if ( $reject_pct >= self::FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE ) {
     642                    if ( $rejections_percentage >= self::FLAG_REJECTION_CRITICAL_THRESHOLD_PERCENTAGE ) {
    631643                        $rejections_level = 'very_likely';
     644                        $message = __( 'very high rejection rate (<strong>%d%%</strong>)', 'wporg-photos' );
    632645                    }
    633                     elseif ( $reject_pct >= self::FLAG_REJECTION_WARNING_THRESHOLD_PERCENTAGE ) {
     646                    elseif ( $rejections_percentage >= self::FLAG_REJECTION_ALERT_THRESHOLD_PERCENTAGE ) {
     647                        $rejections_level = 'likely';
     648                        $message = __( 'high rejection rate (<strong>%d%%</strong>)', 'wporg-photos' );
     649                    }
     650                    elseif ( $rejections_percentage >= self::FLAG_REJECTION_WARNING_THRESHOLD_PERCENTAGE ) {
    634651                        $rejections_level = 'possible';
     652                        $message = __( 'rejection rate (<strong>%d%%</strong>)', 'wporg-photos' );
    635653                    }
    636654                }
    637655
    638                 if ( $rejections_level ) {
    639                     $flags[ sprintf( 'has rejections (<strong>%d</strong>)', $rejections_count ) ] = $rejections_level;
     656                if ( $rejections_level && $message ) {
     657                    $flags[ sprintf( $message, round( $rejections_percentage * 100 , 0 ) ) ] = $rejections_level;
    640658                }
    641659            }
Note: See TracChangeset for help on using the changeset viewer.