-
Notifications
You must be signed in to change notification settings - Fork 8
/
convertDBto200406_render
executable file
·49 lines (39 loc) · 1.36 KB
/
convertDBto200406_render
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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 http://slashcode.com/.
# $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};
createEnvironment($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);
}