Updating these views and adding a third one to list the rchives with their status.

This commit is contained in:
Eric van der Vlist 2020-05-05 20:38:38 +02:00
parent 4ef5fe2994
commit ba2cc3ec40
1 changed files with 23 additions and 10 deletions

View File

@ -188,7 +188,7 @@ if (!class_exists("Owark")) {
$sql = "CREATE OR REPLACE VIEW {$wpdb->prefix}owark_broken_links AS $sql = "CREATE OR REPLACE VIEW {$wpdb->prefix}owark_broken_links AS
SELECT SELECT
owark.id as id, owark.id as id,
instances.raw_url as url, owark.url as url,
instances.container_id as container_id, instances.container_id as container_id,
instances.container_type as container_type, instances.container_type as container_type,
instances.container_field as container_field instances.container_field as container_field
@ -198,21 +198,34 @@ if (!class_exists("Owark")) {
{$wpdb->prefix}blc_instances AS instances {$wpdb->prefix}blc_instances AS instances
WHERE WHERE
owark.url = instances.raw_url owark.url = instances.raw_url
AND instances.link_id = links.link_id
AND broken = 1 AND broken = 1
AND last_check is not null AND last_check is not null
AND instances.link_id = links.link_id"; AND instances.link_id = links.link_id";
print_r_log("sql: $sql"); print_r_log("sql: $sql");
$wpdb->query($sql); $wpdb->query($sql);
$sql = "CREATE OR REPLACE VIEW {$wpdb->prefix}owark_links_to_ckeck AS $sql = "CREATE OR REPLACE VIEW {$wpdb->prefix}owark_archives AS
SELECT
owark.*,
links.broken,
links.first_failure
FROM
{$wpdb->prefix}owark as owark,
{$wpdb->prefix}blc_links as links,
{$wpdb->prefix}blc_instances AS instances
WHERE
owark.url = instances.raw_url
AND instances.link_id = links.link_id
GROUP BY owark.url";
print_r_log("sql: $sql");
$wpdb->query($sql);
$sql = "CREATE OR REPLACE VIEW {$wpdb->prefix}owark_links_to_archive AS
SELECT SELECT
DISTINCT instances.raw_url as url DISTINCT instances.raw_url as url
FROM FROM
{$wpdb->prefix}blc_links as links, {$wpdb->prefix}blc_links as links,
{$wpdb->prefix}blc_instances AS instances {$wpdb->prefix}blc_instances AS instances
WHERE WHERE
instances.link_id = links.link_id broken = 0
AND broken = 0
AND instances.link_id = links.link_id AND instances.link_id = links.link_id
AND url NOT IN (SELECT url FROM wp_owark)"; AND url NOT IN (SELECT url FROM wp_owark)";
print_r_log("sql: $sql"); print_r_log("sql: $sql");
@ -350,10 +363,10 @@ if (!class_exists("Owark")) {
echo '<p>List of broken links with archived pages:</p>'; echo '<p>List of broken links with archived pages:</p>';
$query = "SELECT owark.id, owark.url, owark.status, owark.arc_date, owark.arc_location, blc_links.status_text $query = "SELECT *
FROM {$wpdb->prefix}owark AS owark, {$wpdb->prefix}blc_links as blc_links FROM {$wpdb->prefix}owark_archives
WHERE owark.url = blc_links.final_url COLLATE latin1_swedish_ci and blc_links.broken = 1 WHERE broken = 1
ORDER BY owark.url"; ORDER BY url";
$results = $wpdb->get_results($query); $results = $wpdb->get_results($query);
echo '<table class="widefat">'; echo '<table class="widefat">';
@ -681,7 +694,7 @@ if (!class_exists("Owark")) {
global $wpdb; global $wpdb;
$query = " $query = "
SELECT url from {$wpdb->prefix}owark_links_to_ckeck"; SELECT url from {$wpdb->prefix}owark_links_to_archive";
print_r_log("query: $query"); print_r_log("query: $query");
$url = $wpdb->get_row($query); $url = $wpdb->get_row($query);