Wikipedia:Database reports/Unusually long user blocks/Configuration

This report is updated every 28 days.

Source code

/*
Copyright 2008, 2013 bjweeks, MZMcBride, Tim Landscheidt
Copyright 2021 Kunal Mehta <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

use anyhow::Result;
use dbreps2::{escape_reason, str_vec, Frequency, Report};
use mysql_async::prelude::*;
use mysql_async::Conn;

pub struct Row {
    ipb_address: String,
    actor_name: String,
    ipb_timestamp: String,
    ipb_expiry: String,
    comment_text: String,
}

pub struct ExcessiveUsers {}

impl Report<Row> for ExcessiveUsers {
    fn title(&self) -> &'static str {
        "Unusually long user blocks"
    }

    fn frequency(&self) -> Frequency {
        Frequency::Monthly
    }

    fn query(&self) -> &'static str {
        r#"
/* excessiveusers.rs SLOW_OK */
SELECT
  ipb_address,
  actor_name,
  ipb_timestamp,
  ipb_expiry,
  comment_text
FROM
  ipblocks
  INNER JOIN actor_ipblocks ON ipb_by_actor = actor_id
  INNER JOIN comment_ipblocks ON ipb_reason_id = comment_id
WHERE
  ipb_expiry > DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 2 YEAR), '%Y%m%d%H%i%s')
  AND ipb_expiry != "infinity"
  AND ipb_user != 0;
"#
    }

    async fn run_query(&self, conn: &mut Conn) -> Result<Vec<Row>> {
        let rows = conn
            .query_map(
                self.query(),
                |(
                    ipb_address,
                    actor_name,
                    ipb_timestamp,
                    ipb_expiry,
                    comment_text,
                )| Row {
                    ipb_address,
                    actor_name,
                    ipb_timestamp,
                    ipb_expiry,
                    comment_text,
                },
            )
            .await?;
        Ok(rows)
    }

    fn intro(&self) -> &'static str {
        "Unusually long (more than two years) blocks of users"
    }

    fn headings(&self) -> Vec<&'static str> {
        vec!["User", "Admin", "Timestamp", "Expiry", "Reason"]
    }

    fn format_row(&self, row: &Row) -> Vec<String> {
        str_vec![
            format!("{{{{User|1={}}}}}", &row.ipb_address),
            format!("[[User talk:{}|]]", &row.actor_name),
            row.ipb_timestamp,
            row.ipb_expiry,
            escape_reason(&row.comment_text)
        ]
    }

    fn code(&self) -> &'static str {
        include_str!("excessiveusers.rs")
    }
}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.