diff --git a/dbreps2/src/enwiki.rs b/dbreps2/src/enwiki.rs index e16ceb3..ffa887f 100644 --- a/dbreps2/src/enwiki.rs +++ b/dbreps2/src/enwiki.rs @@ -17,7 +17,6 @@ along with this program. If not, see . mod boteditcount; mod brokenwikiprojtemps; mod editcount; -mod emptycats; mod featuredbysize; mod goodarticlesbysize; mod newprojects; @@ -27,14 +26,8 @@ mod potenshbdps4; mod potenshblps2; mod projectchanges; mod stickyprodblps; -mod templatesnonfree; mod unbelievablelifespans; -mod uncatunrefblps; -mod unsourcedblps; -mod untaggedblps; -mod untaggedstubs; mod untaggedunrefblps; -mod unusednonfree; mod unusedtemplates; mod unusedtemplatesfiltered; mod usercats; @@ -42,17 +35,13 @@ mod webhostpages; pub use { boteditcount::BotEditCount, brokenwikiprojtemps::BrokenWikiProjTemps, - editcount::EditCount, emptycats::EmptyCats, featuredbysize::FeaturedBySize, + editcount::EditCount, featuredbysize::FeaturedBySize, goodarticlesbysize::GoodArticlesBySize, newprojects::NewProjects, orphanedafds::OrphanedAfds, orphanedsubtalks::OrphanedSubTalks, potenshbdps4::Potenshbdps4, potenshblps2::Potenshblps2, projectchanges::ProjectChanges, stickyprodblps::StickyProdBLPs, - templatesnonfree::TemplatesNonFree, unbelievablelifespans::UnbelievableLifeSpans, - uncatunrefblps::UncatUnrefBLPs, unsourcedblps::UnsourcedBLPs, - untaggedblps::UntaggedBLPs, untaggedstubs::UntaggedStubs, - untaggedunrefblps::UntaggedUnrefBLPs, unusednonfree::UnusedNonFree, - unusedtemplates::UnusedTemplates, + untaggedunrefblps::UntaggedUnrefBLPs, unusedtemplates::UnusedTemplates, unusedtemplatesfiltered::UnusedTemplatesFiltered, usercats::UserCats, webhostpages::WebhostPages, }; diff --git a/dbreps2/src/enwiki/emptycats.rs b/dbreps2/src/enwiki/emptycats.rs deleted file mode 100644 index 319473c..0000000 --- a/dbreps2/src/enwiki/emptycats.rs +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright 2008, 2013 bjweeks, MZMcBride, CBM, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - category: String, - length: u32, -} - -pub struct EmptyCats {} - -impl Report for EmptyCats { - fn title(&self) -> &'static str { - "Empty categories" - } - - fn frequency(&self) -> Frequency { - Frequency::DailyAt(1) - } - - fn query(&self) -> &'static str { - r#" -/* emptycats.rs SLOW_OK */ -SELECT - page_title, - page_len -FROM - categorylinks - RIGHT JOIN page ON cl_to = page_title -WHERE - page_namespace = 14 - AND page_is_redirect = 0 - AND cl_to IS NULL - AND NOT( - CONVERT(page_title USING utf8) REGEXP '(-importance|-class|assess|_articles_missing_|_articles_in_need_of_|_articles_undergoing_|_articles_to_be_|_articles_not_yet_|_articles_with_|_articles_without_|_articles_needing_|Wikipedia_featured_topics)' - ) - AND NOT EXISTS ( - SELECT - 1 - FROM - categorylinks - WHERE - cl_from = page_id - AND ( - cl_to = 'Wikipedia_soft_redirected_categories' - OR cl_to = 'Disambiguation_categories' - OR cl_to = 'Monthly_clean-up_category_counter' - OR cl_to LIKE 'Empty_categories%' - ) - ) - AND NOT EXISTS ( - SELECT - 1 - FROM - templatelinks - JOIN linktarget ON tl_target_id = lt_id - WHERE - tl_from = page_id - AND lt_namespace = 10 - AND ( - lt_title = 'Empty_category' - OR lt_title = 'Possibly_empty_category' - OR lt_title = 'Monthly_clean-up_category' - OR lt_title = 'Maintenance_category_autotag' - ) - ); -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |(category, length)| Row { - category, - length, - }) - .await?; - Ok(rows) - } - - fn intro(&self) -> &'static str { - "Empty categories not in [[:Category:Wikipedia soft redirected \ - categories]], not in [[:Category:Disambiguation categories]], not \ - in [[:Category:Monthly clean-up category counter]], not tagged with \ - {{tl|Maintenance category autotag}}, and not containing \"(-importance\ - |\\-class|assess|articles missing|articles in need of|articles \ - undergoing|articles to be|articles not yet|articles with|articles \ - without|articles needing|Wikipedia featured topics)\"" - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Category", "Length"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("{{{{clh|1={}}}}}", row.category), row.length] - } - - fn code(&self) -> &'static str { - include_str!("emptycats.rs") - } -} diff --git a/dbreps2/src/enwiki/potenshbdps4.rs b/dbreps2/src/enwiki/potenshbdps4.rs index d4d13a0..e990770 100644 --- a/dbreps2/src/enwiki/potenshbdps4.rs +++ b/dbreps2/src/enwiki/potenshbdps4.rs @@ -23,7 +23,7 @@ use mysql_async::Conn; pub struct Row { page_title: String, - cl_to: String, + lt_title: String, } pub struct Potenshbdps4 {} @@ -78,7 +78,10 @@ WHERE .exec_map( self.query(), (format!("{year}_births"),), - |(page_title, cl_to)| Row { page_title, cl_to }, + |(page_title, lt_title)| Row { + page_title, + lt_title, + }, ) .await?; //dbg!((year, year_rows.len())); @@ -96,7 +99,7 @@ WHERE } fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[{}]]", row.page_title), linker(14, &row.cl_to)] + str_vec![format!("[[{}]]", row.page_title), linker(14, &row.lt_title)] } fn code(&self) -> &'static str { diff --git a/dbreps2/src/enwiki/templatesnonfree.rs b/dbreps2/src/enwiki/templatesnonfree.rs deleted file mode 100644 index c72ee5a..0000000 --- a/dbreps2/src/enwiki/templatesnonfree.rs +++ /dev/null @@ -1,92 +0,0 @@ -/* -Copyright 2008, 2013 bjweeks, MZMcBride, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, - count: u64, -} - -pub struct TemplatesNonFree {} - -impl Report for TemplatesNonFree { - fn title(&self) -> &'static str { - "Templates containing non-free files" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r#" -/* templatesnonfree.rs SLOW_OK */ -SELECT - imgtmp.page_title, - COUNT(cl_to) -FROM - page AS pg1 - JOIN categorylinks ON cl_from = pg1.page_id - JOIN ( - SELECT - pg2.page_namespace, - pg2.page_title, - il_to - FROM - page AS pg2 - JOIN imagelinks ON il_from = page_id - WHERE - pg2.page_namespace = 10 - ) AS imgtmp ON il_to = pg1.page_title -WHERE - pg1.page_namespace = 6 - AND cl_to = 'All_non-free_media' -GROUP BY - imgtmp.page_namespace, - imgtmp.page_title -ORDER BY - COUNT(cl_to) ASC; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |(page_title, count)| Row { - page_title, - count, - }) - .await?; - Ok(rows) - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Template", "Non-free files"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[Template:{}|]]", row.page_title), row.count] - } - - fn code(&self) -> &'static str { - include_str!("templatesnonfree.rs") - } -} diff --git a/dbreps2/src/enwiki/unbelievablelifespans.rs b/dbreps2/src/enwiki/unbelievablelifespans.rs index af5dea7..d42b18a 100644 --- a/dbreps2/src/enwiki/unbelievablelifespans.rs +++ b/dbreps2/src/enwiki/unbelievablelifespans.rs @@ -52,16 +52,22 @@ FROM SELECT page_namespace, page_title AS page_title, - CAST(SUBSTRING_INDEX(cl3.cl_to, '_', 1) AS UNSIGNED) AS deathyear + CAST(SUBSTRING_INDEX(lt3.lt_title, '_', 1) AS UNSIGNED) AS deathyear FROM categorylinks AS cl1 + JOIN linktarget AS lt1 ON cl1.cl_target_id = lt1.lt_id LEFT JOIN categorylinks AS cl2 ON cl1.cl_from = cl2.cl_from - AND cl2.cl_to IN ('Longevity_traditions', 'Longevity_claims') + LEFT JOIN linktarget AS lt2 ON cl2.cl_target_id = lt2.lt_id + AND lt2.lt_namespace = 14 + AND lt2.lt_title IN ('Longevity_traditions', 'Longevity_claims') JOIN categorylinks AS cl3 ON cl1.cl_from = cl3.cl_from - AND cl3.cl_to REGEXP '^[0-9]+_deaths$' + JOIN linktarget AS lt3 ON cl3.cl_target_id = lt3.lt_id + AND lt3.lt_namespace = 14 + AND lt3.lt_title REGEXP '^[0-9]+_deaths$' JOIN page ON page_id = cl1.cl_from WHERE - cl1.cl_to = CONCAT(?, '_births') + lt1.lt_namespace = 14 + AND lt1.lt_title = CONCAT(?, '_births') AND cl2.cl_from IS NULL ) AS BornAndDeads WHERE diff --git a/dbreps2/src/enwiki/uncatunrefblps.rs b/dbreps2/src/enwiki/uncatunrefblps.rs deleted file mode 100644 index 74e1868..0000000 --- a/dbreps2/src/enwiki/uncatunrefblps.rs +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2011, 2013 bjweeks, MZMcBride, WOSlinker, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, -} - -pub struct UncatUnrefBLPs {} - -impl Report for UncatUnrefBLPs { - fn title(&self) -> &'static str { - "Uncategorized and unreferenced biographies of living people" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r#" -/* uncatunrefblps.rs SLOW_OK */ -SELECT - DISTINCT page_title -FROM - page - JOIN categorylinks AS cl1 ON cl1.cl_from = page_id - LEFT JOIN categorylinks AS cl2 ON cl2.cl_from = page_id - AND cl2.cl_to NOT REGEXP '(Living_people|[0-9]+_births)' - AND cl2.cl_to NOT IN ( - SELECT - page_title - FROM - page - JOIN categorylinks ON cl_from = page_id - WHERE - page_namespace = 14 - AND cl_to IN ('Wikipedia_maintenance', 'Hidden_categories') - ) -WHERE - cl1.cl_to = 'All_unreferenced_BLPs' - AND page_namespace = 0 - AND cl2.cl_from IS NULL; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |page_title| Row { page_title }) - .await?; - Ok(rows) - } - - fn intro(&self) -> &'static str { - "Pages in [[:Category:All unreferenced BLPs]] in need of proper categorization" - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Biography"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[{}]]", row.page_title)] - } - - fn code(&self) -> &'static str { - include_str!("uncatunrefblps.rs") - } -} diff --git a/dbreps2/src/enwiki/unsourcedblps.rs b/dbreps2/src/enwiki/unsourcedblps.rs deleted file mode 100644 index 160fcd2..0000000 --- a/dbreps2/src/enwiki/unsourcedblps.rs +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright 2011, 2013 bjweeks, MZMcBride, WOSlinker, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, -} - -pub struct UnsourcedBLPs {} - -impl Report for UnsourcedBLPs { - fn title(&self) -> &'static str { - "Biographies of living people containing unsourced statements" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r#" -/* unsourcedblps.rs SLOW_OK */ -SELECT - page_title -FROM - page - JOIN templatelinks ON tl_from = page_id - JOIN linktarget ON tl_target_id = lt_id - JOIN categorylinks ON cl_from = page_id -WHERE - cl_to = 'Living_people' - AND lt_namespace = 10 - AND lt_title = 'Citation_needed' - AND page_namespace = 0 -LIMIT - 500; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |page_title| Row { page_title }) - .await?; - Ok(rows) - } - - fn intro(&self) -> &'static str { - "{{NOINDEX}}{{shortcut|WP:DR/BLP}}\nPages in [[:Category:Living people]] that \ - [[Special:WhatLinksHere/Template:Citation needed|transclude]] \ - [[Template:Citation needed]] (limited to the first 500 entries)" - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Article"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("{{{{ple|1={}}}}}", row.page_title)] - } - - fn code(&self) -> &'static str { - include_str!("unsourcedblps.rs") - } -} diff --git a/dbreps2/src/enwiki/untaggedblps.rs b/dbreps2/src/enwiki/untaggedblps.rs deleted file mode 100644 index c1df3cc..0000000 --- a/dbreps2/src/enwiki/untaggedblps.rs +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2010, 2013 bjweeks, MZMcBride, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, -} - -pub struct UntaggedBLPs {} - -impl Report for UntaggedBLPs { - fn title(&self) -> &'static str { - "Untagged biographies of living people" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r#" -/* untaggedblps.rs SLOW_OK */ -SELECT - p1.page_title -FROM - page AS p1 - JOIN categorylinks ON cl_from = p1.page_id -WHERE - cl_to = 'Living_people' - AND p1.page_namespace = 0 - AND NOT EXISTS ( - SELECT - 1 - FROM - page AS p2 - WHERE - p2.page_title = p1.page_title - AND p2.page_namespace = 1 - ) -LIMIT - 1000; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |page_title| Row { page_title }) - .await?; - Ok(rows) - } - - fn intro(&self) -> &'static str { - "Pages in [[:Category:Living people]] missing WikiProject tags \ - (limited to the first 1000 entries)" - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Biography"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[{}]]", row.page_title)] - } - - fn code(&self) -> &'static str { - include_str!("untaggedblps.rs") - } -} diff --git a/dbreps2/src/enwiki/untaggedstubs.rs b/dbreps2/src/enwiki/untaggedstubs.rs deleted file mode 100644 index 374497e..0000000 --- a/dbreps2/src/enwiki/untaggedstubs.rs +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2010, 2013 bjweeks, MZMcBride, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, - page_len: u64, -} - -pub struct UntaggedStubs {} - -impl Report for UntaggedStubs { - fn title(&self) -> &'static str { - "Untagged stubs" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r" -/* untaggedstubs.rs SLOW_OK */ -SELECT - page_title, - page_len -FROM - page - LEFT JOIN categorylinks ON cl_from = page_id - AND ( - cl_to LIKE '%_stubs' - OR cl_to LIKE 'Redirects_to_Wiki%' - OR cl_to LIKE 'Lists_of_%' - OR cl_to IN ( - 'All_disambiguation_pages', - 'All_set_index_articles', - 'Redirects_to_Wiktionary', - 'Wikipedia_soft_redirects', - 'All_redirects_for_discussion' - ) - ) -WHERE - page_namespace = 0 - AND page_is_redirect = 0 - AND page_title NOT LIKE 'List\\_of\\_%' - AND page_title NOT LIKE 'Lists\\_of\\_%' - AND cl_from IS NULL - AND page_len < 1500 -LIMIT - 1000; -" - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |(page_title, page_len)| Row { - page_title, - page_len, - }) - .await?; - Ok(rows) - } - - fn intro(&self) -> &'static str { - "Untagged stubs (limited to the first 1000 entries)" - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Title", "Length"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[{}]]", row.page_title), row.page_len] - } - - fn code(&self) -> &'static str { - include_str!("untaggedstubs.rs") - } -} diff --git a/dbreps2/src/enwiki/untaggedunrefblps.rs b/dbreps2/src/enwiki/untaggedunrefblps.rs index 0cf0b58..da8b40c 100644 --- a/dbreps2/src/enwiki/untaggedunrefblps.rs +++ b/dbreps2/src/enwiki/untaggedunrefblps.rs @@ -43,13 +43,15 @@ impl Report for UntaggedUnrefBLPs { /* untaggedunrefblps.rs SLOW_OK */ SELECT p1.page_title, - GROUP_CONCAT(cl2.cl_to SEPARATOR '|') + GROUP_CONCAT(cl2.cl_target_id SEPARATOR '|') FROM page AS p1 JOIN categorylinks AS cl1 ON cl1.cl_from = p1.page_id + JOIN linktarget AS lt1 ON cl1.cl_target_id = lt1.lt_id JOIN categorylinks AS cl2 ON cl2.cl_from = p1.page_id + JOIN linktarget AS lt2 ON cl2.cl_target_id = lt2.lt_id WHERE - cl1.cl_to = 'All_unreferenced_BLPs' + lt1.lt_title = 'All_unreferenced_BLPs' AND p1.page_namespace = 0 AND NOT EXISTS ( SELECT diff --git a/dbreps2/src/enwiki/unusednonfree.rs b/dbreps2/src/enwiki/unusednonfree.rs deleted file mode 100644 index 66d533d..0000000 --- a/dbreps2/src/enwiki/unusednonfree.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2010, 2013 bjweeks, MZMcBride, Tim Landscheidt -Copyright 2021 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, -} - -pub struct UnusedNonFree {} - -impl Report for UnusedNonFree { - fn title(&self) -> &'static str { - "Unused non-free files" - } - - fn frequency(&self) -> Frequency { - Frequency::Daily - } - - fn query(&self) -> &'static str { - r#" -/* unusednonfree.rs SLOW_OK */ -SELECT img.page_title -FROM categorylinks AS c1 -JOIN page AS img ON img.page_id = c1.cl_from -LEFT JOIN categorylinks AS c2 ON c2.cl_from = c1.cl_from AND c2.cl_to = 'All_orphaned_non-free_use_Wikipedia_files' -LEFT JOIN imagelinks ON il_to = img.page_title AND il_from_namespace = 0 -WHERE img.page_namespace = 6 - AND c1.cl_to = 'All_non-free_media' - AND c2.cl_from IS NULL - AND il_from IS NULL - AND img.page_is_redirect = 0 - AND NOT EXISTS - (SELECT 1 - FROM redirect - JOIN page AS rdr ON rdr.page_id = rd_from - JOIN imagelinks ON il_to = rdr.page_title AND il_from_namespace = 0 - WHERE rd_namespace = 6 - AND rd_title = img.page_title - AND rdr.page_namespace = 6) -ORDER BY page_title ASC; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |page_title| Row { page_title }) - .await?; - Ok(rows) - } - - fn headings(&self) -> Vec<&'static str> { - vec!["File"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![format!("[[:File:{}|]]", row.page_title)] - } - - fn code(&self) -> &'static str { - include_str!("unusednonfree.rs") - } -} diff --git a/dbreps2/src/enwiki/unusedtemplates.rs b/dbreps2/src/enwiki/unusedtemplates.rs index 85bc4ac..06dd0fd 100644 --- a/dbreps2/src/enwiki/unusedtemplates.rs +++ b/dbreps2/src/enwiki/unusedtemplates.rs @@ -88,19 +88,20 @@ FROM page LEFT JOIN linktarget ON page_namespace = lt_namespace AND page_title = lt_title -LEFT JOIN templatelinks ON tl_target_id=lt_id +LEFT JOIN templatelinks ON tl_target_id = lt_id WHERE page_namespace = 10 AND page_is_redirect = 0 AND tl_target_id IS NULL AND page_title NOT IN ( SELECT - page_title + page.page_title FROM page JOIN categorylinks ON page_id = cl_from + JOIN linktarget AS lt_cat ON cl_target_id = lt_cat.lt_id WHERE - cl_to IN ( + lt_cat.lt_title IN ( 'Wikipedia_substituted_templates', 'Wikipedia_transclusionless_templates', 'Deprecated_templates_kept_for_historical_reasons', diff --git a/dbreps2/src/enwiki/unusedtemplatesfiltered.rs b/dbreps2/src/enwiki/unusedtemplatesfiltered.rs index 865e834..f5d81ab 100644 --- a/dbreps2/src/enwiki/unusedtemplatesfiltered.rs +++ b/dbreps2/src/enwiki/unusedtemplatesfiltered.rs @@ -84,7 +84,7 @@ FROM page LEFT JOIN linktarget ON page_namespace = lt_namespace AND page_title = lt_title -LEFT JOIN templatelinks ON tl_target_id=lt_id +LEFT JOIN templatelinks ON tl_target_id = lt_id WHERE page_namespace = 10 AND page_is_redirect = 0 @@ -108,12 +108,13 @@ WHERE AND page_title NOT LIKE "%-stub" AND page_title NOT IN ( SELECT - page_title + page.page_title FROM page JOIN categorylinks ON page_id = cl_from + JOIN linktarget AS lt_cat ON cl_target_id = lt_cat.lt_id WHERE - cl_to IN ( + lt_cat.lt_title IN ( 'Wikipedia_substituted_templates', 'Wikipedia_transclusionless_templates', 'Deprecated_templates_kept_for_historical_reasons', diff --git a/dbreps2/src/general.rs b/dbreps2/src/general.rs index a957212..c2f510b 100644 --- a/dbreps2/src/general.rs +++ b/dbreps2/src/general.rs @@ -26,7 +26,6 @@ mod linkedredlinkedcats; mod oldeditors; mod ownerlessuserpages; mod pollcats; -mod selfcatcats; mod uncatcats; mod userarticlestreaks; mod userlinksinarticles; @@ -38,7 +37,7 @@ pub use { excessiveusers::ExcessiveUsers, indeffullredirects::IndefFullRedirects, indefips::IndefIPs, linkedemailsinarticles::LinkedEmailsInArticles, oldeditors::OldEditors, ownerlessuserpages::Ownerlessuserpages, - pollcats::Pollcats, selfcatcats::SelfCatCats, uncatcats::UncatCats, + pollcats::Pollcats, uncatcats::UncatCats, userarticlestreaks::UserArticleStreaks, userlinksinarticles::UserLinksInArticles, userstreaks::UserStreaks, }; diff --git a/dbreps2/src/general/linkedredlinkedcats.rs b/dbreps2/src/general/linkedredlinkedcats.rs index 4b19cd5..63952e4 100644 --- a/dbreps2/src/general/linkedredlinkedcats.rs +++ b/dbreps2/src/general/linkedredlinkedcats.rs @@ -23,7 +23,7 @@ use mysql_async::Conn; // Temporarily disabled because it's too slow #[allow(dead_code)] pub struct Row { - cl_to: String, + lt_title: String, count: u64, } @@ -43,16 +43,16 @@ impl Report for LinkedRedlinkedCats { r#" /* linkedredlinkedcats.rs SLOW_OK */ SELECT - cl_to, + lt_cat.lt_title, COUNT(*) FROM - /* FIXME when categorylinks gets normalized as well */ categorylinks - JOIN linktarget ON lt_title = cl_to AND lt_namespace = 14 - JOIN pagelinks ON pl_target_id = lt_id + JOIN linktarget AS lt_cat ON cl_target_id = lt_cat.lt_id + JOIN linktarget AS lt_pl ON lt_pl.lt_title = lt_cat.lt_title AND lt_pl.lt_namespace = 14 + JOIN pagelinks ON pl_target_id = lt_pl.lt_id JOIN page AS p1 ON pl_from = p1.page_id AND p1.page_namespace IN (0, 6, 10, 12, 14, 100) - LEFT JOIN page AS p2 ON cl_to = p2.page_title + LEFT JOIN page AS p2 ON lt_cat.lt_title = p2.page_title AND p2.page_namespace = 14 WHERE p2.page_title IS NULL @@ -65,7 +65,10 @@ LIMIT async fn run_query(&self, conn: &mut Conn) -> Result> { let rows = conn - .query_map(self.query(), |(cl_to, count)| Row { cl_to, count }) + .query_map(self.query(), |(lt_title, count)| Row { + lt_title, + count, + }) .await?; Ok(rows) } @@ -78,7 +81,7 @@ LIMIT str_vec![ format!( "[[Special:WhatLinksHere/Category:{}|{}]]", - &row.cl_to, &row.cl_to + &row.lt_title, &row.lt_title ), row.count ] diff --git a/dbreps2/src/general/selfcatcats.rs b/dbreps2/src/general/selfcatcats.rs deleted file mode 100644 index 533c420..0000000 --- a/dbreps2/src/general/selfcatcats.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2008, 2013 bjweeks, MZMcBride, Tim Landscheidt -Copyright 2024 Kunal Mehta - -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 . - */ - -use anyhow::Result; -use dbreps2::{linker, str_vec, Frequency, Report}; -use mysql_async::prelude::*; -use mysql_async::Conn; - -pub struct Row { - page_title: String, - cat_pages: u64, - cat_subcats: u64, -} - -pub struct SelfCatCats {} - -impl Report for SelfCatCats { - fn title(&self) -> &'static str { - "Self-categorized categories" - } - - fn frequency(&self) -> Frequency { - Frequency::Weekly - } - - fn query(&self) -> &'static str { - r#" -/* selfcatcats.rs SLOW_OK */ -SELECT - page_title, - cat_pages, - cat_subcats -FROM page -JOIN categorylinks -ON cl_to = page_title -RIGHT JOIN category -ON cat_title = page_title -WHERE page_id = cl_from -AND page_namespace = 14; -"# - } - - async fn run_query(&self, conn: &mut Conn) -> Result> { - let rows = conn - .query_map(self.query(), |(page_title, cat_pages, cat_subcats)| { - Row { - page_title, - cat_pages, - cat_subcats, - } - }) - .await?; - Ok(rows) - } - - fn headings(&self) -> Vec<&'static str> { - vec!["Category", "Members", "Subcategories"] - } - - fn format_row(&self, row: &Row) -> Vec { - str_vec![linker(14, &row.page_title), row.cat_pages, row.cat_subcats] - } - - fn code(&self) -> &'static str { - include_str!("selfcatcats.rs") - } -} diff --git a/dbreps2/src/main.rs b/dbreps2/src/main.rs index a576892..352a103 100644 --- a/dbreps2/src/main.rs +++ b/dbreps2/src/main.rs @@ -57,7 +57,6 @@ async fn main() -> Result<()> { .really_run(&enwiki_runner) .await; (general::Pollcats {}).really_run(&enwiki_runner).await; - (general::SelfCatCats {}).really_run(&enwiki_runner).await; (general::UncatCats {}).really_run(&enwiki_runner).await; (general::UserLinksInArticles {}) .really_run(&enwiki_runner) @@ -67,7 +66,6 @@ async fn main() -> Result<()> { .await; (enwiki::BotEditCount {}).really_run(&enwiki_runner).await; (enwiki::EditCount {}).really_run(&enwiki_runner).await; - (enwiki::EmptyCats {}).really_run(&enwiki_runner).await; (enwiki::FeaturedBySize { // FIXME: figure out a less terrible way to do this bot: enwiki_runner.bot.clone(), @@ -89,20 +87,12 @@ async fn main() -> Result<()> { (enwiki::Potenshblps2 {}).really_run(&enwiki_runner).await; (enwiki::ProjectChanges {}).really_run(&enwiki_runner).await; (enwiki::StickyProdBLPs {}).really_run(&enwiki_runner).await; - (enwiki::TemplatesNonFree {}) - .really_run(&enwiki_runner) - .await; (enwiki::UnbelievableLifeSpans {}) .really_run(&enwiki_runner) .await; - (enwiki::UncatUnrefBLPs {}).really_run(&enwiki_runner).await; - (enwiki::UnsourcedBLPs {}).really_run(&enwiki_runner).await; - (enwiki::UntaggedBLPs {}).really_run(&enwiki_runner).await; - (enwiki::UntaggedStubs {}).really_run(&enwiki_runner).await; (enwiki::UntaggedUnrefBLPs {}) .really_run(&enwiki_runner) .await; - (enwiki::UnusedNonFree {}).really_run(&enwiki_runner).await; (enwiki::UnusedTemplates {}) .really_run(&enwiki_runner) .await;