Permalink
Browse files

Some feedback on what it is doing, and only delete the old when reall…

…y needed... which should keep the website more populated during updates which take rather long

git-svn-id: https://blueobelisk.svn.sf.net/svnroot/blueobelisk/cb/trunk@162 d3c5a50b-8e31-0410-8099-a759d7a8ce2e
  • Loading branch information...
1 parent 94112f4 commit b65f2d16762cdc6121f2ef59757a468e56305f28 egonw committed Nov 16, 2007
Showing with 12 additions and 5 deletions.
  1. +12 −5 generate_summaries.pl
View
@@ -17,15 +17,11 @@
my $db = DBI->connect($connection_string, $config{"db_user"}, $config{"db_password"}) or log_error("Couldn't connect to the database.\n");
# let's only summarize links from the past x days.
-my $age_limit = 90;
+my $age_limit = 30;
# we have two "summary" tables, for links and posts
my $sql = $db->prepare("DELETE FROM links_summary");
$sql->execute();
-my $sql = $db->prepare("DELETE FROM posts_summary");
-$sql->execute();
-my $sql = $db->prepare("DELETE FROM papers_summary");
-$sql->execute();
# repopulate the tables with data
my $sql = $db->prepare("SET group_concat_max_len = 4096");
@@ -39,13 +35,21 @@
");
$sql->execute($age_limit);
+print "Done repopulation links...\n";
+
+my $sql = $db->prepare("DELETE FROM posts_summary");
+$sql->execute();
my $sql = $db->prepare("
INSERT INTO posts_summary
(post_id, blog_id, title, url, url_hash, summary, filename, author, pubdate, added_on, blog_name, blog_image, linked_by)
SELECT posts.post_id, posts.blog_id, posts.title, posts.url, posts.url_hash, posts.summary, posts.filename, posts.author, posts.pubdate, posts.added_on, blogs.title AS blog_name, blogs.image AS blog_image, COUNT(DISTINCT IF(ISNULL(links.blog_id),NULL,IF(links.blog_id = posts.blog_id,NULL,links.blog_id))) AS linked_by FROM blogs, posts LEFT JOIN links ON links.url_hash = posts.url_hash WHERE blogs.blog_id = posts.blog_id GROUP BY posts.url_hash
");
$sql->execute();
+print "Done repopulation posts...\n";
+
+my $sql = $db->prepare("DELETE FROM papers_summary");
+$sql->execute();
my $sql = $db->prepare("
INSERT INTO papers_summary
(paper_id, isbn_id, image, doi_id, pubmed_id, arxiv_id, pii_id, journal, title, abstract, authors, pubdate, added_on, url, cited_by, reviewed, blog_ids)
@@ -70,3 +74,6 @@
FROM papers LEFT JOIN links ON links.paper_id = papers.paper_id GROUP BY papers.paper_id;
");
$sql->execute();
+
+print "Done repopulation papers...\n";
+

0 comments on commit b65f2d1

Please sign in to comment.