These scripts were for data migration, inherited from LJ. Declutter.
Patch by denise.
diffs (180 lines):
diff -r 12a6d14a9725 -r 357548220e50 bin/upgrading/copy-emailpass-out-of-user
--- a/bin/upgrading/copy-emailpass-out-of-user Sun Feb 14 13:13:08 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#!/usr/bin/perl
-#
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-#
http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-use strict;
-use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
-
-my $dbh = LJ::get_db_writer();
-
-my $max = $dbh->selectrow_array("SELECT MAX(userid) FROM user");
-print "max = $max\n";
-
-my $base = shift || 1;
-my $lastcheck = 0;
-
-my $size = 1000;
-while ($base <= $max) {
- my $upper = $base + $size - 1;
- my $rv = $dbh->do("INSERT IGNORE INTO email (userid, email) SELECT userid,
email FROM user WHERE userid BETWEEN $base AND $upper");
- my $rv2 = $dbh->do("INSERT IGNORE INTO password (userid, password) SELECT
userid, password FROM user WHERE userid BETWEEN $base AND $upper");
- $base += 1000;
-
- my $busy = 0;
-
- my $now = time();
- if ($lastcheck != $now) {
- $lastcheck = $now;
- my $sth = $dbh->prepare("SHOW PROCESSLIST");
- $sth->execute;
- while (my $row = $sth->fetchrow_hashref) {
- next if $row->{Command} eq "Sleep";
- next if $row->{Command} eq "Connect";
- $busy++;
- }
- }
-
- print "$base = $rv / $rv2 b=$busy\n";
- if ($busy > 100) {
- sleep 1;
- } elsif ($busy > 50) {
- select undef, undef, undef, 0.25;
- }
-}
-
diff -r 12a6d14a9725 -r 357548220e50 bin/upgrading/shared-journal-conv
--- a/bin/upgrading/shared-journal-conv Sun Feb 14 13:13:08 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-#! /usr/bin/perl
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-#
http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-# This script scours the database for all shared journals and converts them
-# to closed communities. By its nature, it's restartable at any time, since
-# any account it's processed will no longer be journaltype='S'.
-
-use strict;
-use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
-
-my $dbh = LJ::get_db_writer()
- or die "Unable to get global master database";
-my $dbslo = LJ::get_dbh("slow")
- or die "cannot connect to slow role";
-
-my $uids_done = 0;
-my $total_uids = $dbslo->selectrow_array("SELECT COUNT(*) FROM user WHERE
journaltype='S'");
-print "Preparing to convert $total_uids shared journals...\n";
-
-my $limit = 100;
-
-# scary, i know... but we'll last out if we ever get less than $limit uids
-while (1) {
-
- # Let's call start_request
- # -- so our in-process $u caches don't get unreasonable
- # -- so we revalidate our database handles
- LJ::start_request();
- $dbh = LJ::get_db_writer();
- $dbslo = LJ::get_dbh("slow")
- or die "cannot connect to slow role";
-
- # load user rows from slow
- my $sth = $dbslo->prepare("SELECT * FROM user WHERE journaltype = 'S'
LIMIT $limit");
- $sth->execute;
- die $dbslo->errstr if $dbslo->err;
-
- # construct user objects
- my %user_rows = (); # uid => $row
- while (my $row = $sth->fetchrow_hashref) {
- $user_rows{$row->{userid}} = LJ::User->new_from_row($row);
- }
- last unless %user_rows;
-
-
- # now update each one
- while (my ($uid, $u) = each %user_rows) {
- unless ($u->is_expunged) {
- $dbh->do("REPLACE INTO community VALUES (?, 'closed', 'members')",
undef, $u->id);
- die $dbh->errstr if $dbh->err;
- }
-
- LJ::infohistory_add($u, 'password', Digest::MD5::md5_hex($u->password
. 'change'));
- LJ::update_user($u, { password => '', journaltype => 'C' });
- LJ::statushistory_add($u, LJ::get_userid("system"),
"change_journal_type", "administratively converted to a community");
- $uids_done++;
- }
-
- print "$uids_done / $total_uids converted\n";
-
- # we're done if we got less than the limit
- last if scalar (keys %user_rows) < $limit;
-}
-
-print "All done!\n";
-
-1;
diff -r 12a6d14a9725 -r 357548220e50 bin/upgrading/support-upgrade.pl
--- a/bin/upgrading/support-upgrade.pl Sun Feb 14 13:13:08 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#!/usr/bin/perl
-#
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-#
http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
-
-my $dbh = LJ::get_dbh("master");
-my $sth;
-
-$sth = $dbh->prepare("SELECT spid FROM support WHERE timelasthelp IS NULL");
-$sth->execute;
-while (my ($spid) = $sth->fetchrow_array)
-{
- print "Fixing $spid...\n";
- my $st2 = $dbh->prepare("SELECT MAX(timelogged) FROM supportlog WHERE
spid=$spid AND type='answer'");
- $st2->execute;
- my ($max) = $st2->fetchrow_array;
- $max = $max + 0; # turn undef -> 0
- print " time = $max\n";
- $dbh->do("UPDATE support SET timelasthelp=$max WHERE spid=$spid");
-
-}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog