Skip to content

Commit

Permalink
Merge pull request #142 from mzmcbride/log-db
Browse files Browse the repository at this point in the history
Add log entry for skipped reports
  • Loading branch information
legoktm authored Sep 30, 2024
2 parents 771579b + 21ee8f0 commit af29a71
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions dbreps2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#![allow(async_fn_in_trait)]
use anyhow::Result;
use log::{error, info};
use log::{error, info, warn};
use mwbot::{Bot, Page, SaveOptions};
use mysql_async::{Conn, Pool};
use regex::Regex;
Expand Down Expand Up @@ -196,6 +196,10 @@ pub trait Report<T: Send + Sync> {
// Pages with {{database report}} are maintained by SDZeroBot and contain the SQL queries
// directly. Skip updating the report if it has been migrated to use that template.
if contains_database_report_template(old_text) {
warn!(
"Skipping [[{}]] because it contains {{database report}}",
self.title()
);
return Ok(false);
}
let re = Regex::new("<onlyinclude>(.*?)</onlyinclude>").unwrap();
Expand Down Expand Up @@ -530,17 +534,14 @@ mod tests {

#[test]
fn test_contains_database_report_template() {
assert_eq!(contains_database_report_template(
"Some text here. {{database report|sql=SELECT * FROM page LIMIT 10}}"), true);
assert_eq!(
contains_database_report_template(
"Some text here. \
assert!(contains_database_report_template(
"Some text here. {{database report|sql=SELECT * FROM page LIMIT 10}}"));
assert!(contains_database_report_template(
"Some text here. \
{{database report\
|sql=SELECT * FROM page LIMIT 10\
}}"
),
true
);
assert_eq!(contains_database_report_template("Some text here"), false);
));
assert!(!contains_database_report_template("Some text here"));
}
}

0 comments on commit af29a71

Please sign in to comment.