Fetching contributors…
Cannot retrieve contributors at this time
executable file 50 lines (39 sloc) 1.36 KB
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2005 by Open Source Technology Group. See README
# and COPYING for more information, or see
# $Id$
# This script finishes up an update of old-style to new-style
# stories tables, namely by rendering topic choices from
# story_topics_chosen into story_topics_rendered.
use strict;
use File::Basename;
use Getopt::Std;
use Data::Dumper;
use Slash;
use Slash::Utility;
use vars qw( $slashdb
$stoids );
(my $VERSION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
my $PROGNAME = basename($0);
my (%opts, %family_tree);
# Remember to doublecheck these match usage()!
usage('Options used incorrectly') unless getopts('hu:', \%opts);
usage() if $opts{h};
die "Username required" unless $opts{u};
$slashdb = getCurrentDB();
$stoids = $slashdb->sqlSelectColArrayref("stoid", "stories");
for my $stoid (@$stoids) {
my($primaryskid, $tids) = $slashdb->setStoryRenderedFromChosen($stoid);
# use original tid if it's set and remains in the returned set
my $orig_tid = $slashdb->getStory($stoid, 'tid');
my $tid = $orig_tid if $orig_tid and scalar grep { $_ == $orig_tid } @$tids;
$tid ||= $tids->[0] || 0;
my $update_hr = {
tid => $tid,
primaryskid => $primaryskid,
is_dirty => 1,
$slashdb->setStory($stoid, $update_hr);