Wikipedia:Database reports/Uncategorized templates/Configuration

From Wikipedia, the free encyclopedia

This report is updated every 7 days.

Source code[edit]

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

pub struct Row {
    page_title: String,
}

pub struct UncatTemps {}

impl Report<Row> for UncatTemps {
    fn title(&self) -> &'static str {
        "Uncategorized templates"
    }

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

    fn rows_per_page(&self) -> Option<usize> {
        Some(1000)
    }

    fn query(&self) -> &'static str {
        r#"
/* uncattemps.rs SLOW_OK */
SELECT
  page_title
FROM page
LEFT JOIN categorylinks
ON cl_from = page_id
WHERE page_namespace = 10
AND page_is_redirect = 0
AND ISNULL(cl_from)
AND page_title NOT LIKE '%/%';
"#
    }

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

    fn headings(&self) -> Vec<&'static str> {
        vec!["Template"]
    }

    fn format_row(&self, row: &Row) -> Vec<String> {
        str_vec![dbr_link(&row.page_title)]
    }

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