Permalink
Browse files

Import old stories and journals into Firehose

  • Loading branch information...
1 parent f7fec79 commit d255b25f8579e4bd6191ac35cb8907bf8874db51 @pudge pudge committed Oct 30, 2008
@@ -106,14 +106,14 @@ sub createUpdateItemFromJournal {
if ($journal) {
my $globjid = $self->getGlobjidCreate("journals", $journal->{id});
my $globjid_q = $self->sqlQuote($globjid);
- # XXX does this next line depend on the primary key being the
- # first column returned by "SELECT *"? If I read that right,
- # that's non-intuitive; we should select id by name instead. -Jamie
- my($itemid) = $self->sqlSelect("*", "firehose", "globjid=$globjid_q");
+ my($itemid) = $self->sqlSelect("id", "firehose", "globjid=$globjid_q");
if ($itemid) {
- my $introtext = balanceTags(strip_mode($journal->{article}, $journal->{posttype}), { deep_nesting => 1 });
+ my $bodytext = balanceTags(strip_mode($journal->{article}, $journal->{posttype}), { deep_nesting => 1 });
+ my $introtext = $journal->{introtext} || $bodytext;
+
$self->setFireHose($itemid, {
introtext => $introtext,
+ bodytext => $bodytext,
title => $journal->{description},
tid => $journal->{tid},
discussion => $journal->{discussion},
@@ -42,6 +42,7 @@ sub set {
$self->sqlUpdate('journals', \%j1, "id=$id") if keys %j1;
$self->sqlUpdate('journals_text', \%j2, "id=$id") if $j2{article};
if ($constants->{plugin}{FireHose}) {
+ # XXX: this will not work with HumanConf!
my $reskey = getObject('Slash::ResKey');
my $rkey = $reskey->key('submit', { nostate => 1 });
if ($rkey && $rkey->createuse) {
@@ -196,6 +197,7 @@ sub create {
my $slashdb = getCurrentDB();
$slashdb->setUser($user->{uid}, { journal_last_entry_date => $date });
if ($constants->{plugin}{FireHose}) {
+ # XXX: this will not work with HumanConf!
my $reskey = getObject('Slash::ResKey');
my $rkey = $reskey->key('submit', { nostate => 1 });
if ($rkey && $rkey->createuse) {
@@ -228,7 +230,7 @@ sub remove {
# if has been submitted as story or submission, don't
# delete the discussion
if ($journal->{promotetype} eq 'publicize' || $journal->{promotetype} eq "publish") {
- my $kind = $self->getDiscussion($journal->{discussion}, 'kind');
+ my $kind = $self->getDiscussion($journal->{discussion}, 'dkid');
my $kinds = $self->getDescriptions('discussion_kinds');
# set to disabled only if the journal has not been
# converted to a journal-story (it will get re-enabled
@@ -356,6 +356,7 @@ sub getIRCData {
re => \&cmd_re,
d => \&cmd_roll,
+ amihere => \&cmd_ha,
amiherenow => \&cmd_ha,
amibacknow => \&cmd_ha,
);
@@ -3,24 +3,29 @@ use warnings;
use strict;
use Slash::Test shift || 'slash';
-my $limit = shift || 100;
-
-my $slashdb = getCurrentDB();
-my $ids = $slashdb->sqlSelectColArrayref(
- 'journals.id', 'journals',
- 'journals.id NOT IN (SELECT firehose.srcid FROM firehose WHERE firehose.type = "journal") LIMIT ' . $limit
-);
+my $limit = shift;
+local $| = 1;
my $firehose = getObject("Slash::FireHose");
-local $| = 1;
-printf STDERR "Importing %d journals\n", scalar(@$ids);
+my $journal = getObject("Slash::Journal");
+printf STDERR "Fetching IDs ...\n";
+my $slashdb = getCurrentDB();
+my $ids = $slashdb->sqlSelectColArrayref('id', 'journals', '', ($limit ? "LIMIT $limit" : ()));
my $i = 0;
my %ids;
+
+printf STDERR "\nImporting %d journals\n", scalar(@$ids);
for my $id (@$ids) {
printf "\r%d", ++$i;
+ my $introtext = $journal->getIntrotext($id);
+ $journal->sqlUpdate('journals_text',
+ { introtext => $introtext },
+ "id = " . $journal->sqlQuote($id)
+ );
$ids{$id} = $firehose->createUpdateItemFromJournal($id);
}
+printf STDERR "\nImported %d journals\n", scalar(keys %ids);
-my $string = join ';', map { "$_:$ids{$_}" } @$ids;
+my $string = join '; ', map { "$_:$ids{$_}" } @$ids;
print "\n$string\nDone\n";
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Slash::Test shift || 'slash';
+my $limit = shift;
+local $| = 1;
+
+my $firehose = getObject("Slash::FireHose");
+printf STDERR "Fetching IDs ...\n";
+
+my $slashdb = getCurrentDB();
+my $ids = $slashdb->sqlSelectColArrayref('stoid', 'stories', '', ($limit ? "LIMIT $limit" : ()));
+my $i = 0;
+my %ids;
+
+printf STDERR "\nImporting %d stories\n", scalar(@$ids);
+for my $id (@$ids) {
+ printf "\r%d", ++$i;
+ my $globjid = $slashdb->getGlobjidCreate("stories", $id);
+ my $fhid;
+ $fhid = $firehose->getFireHoseIdFromGlobjid($globjid) if $globjid;
+
+ $ids{$id} = $firehose->createItemFromStory($id) unless $fhid;
+}
+printf STDERR "\nImported %d stories\n", scalar(keys %ids);
+
+my $string = join '; ', map { "$_:$ids{$_}" } sort { $a <=> $b } keys %ids;
+print "\n$string\nDone\n";

0 comments on commit d255b25

Please sign in to comment.