Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r11845: LJSUP-11976 (refactor methods working wi...

Committer: ailyin
LJSUP-11976 (refactor methods working with infohistory into classes of its own)
U   trunk/cgi-bin/LJ/Console/Command/Redirect.pm
U   trunk/cgi-bin/LJ/Sponsored/User.pm
Modified: trunk/cgi-bin/LJ/Console/Command/Redirect.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/Redirect.pm	2012-04-27 11:04:44 UTC (rev 11844)
+++ trunk/cgi-bin/LJ/Console/Command/Redirect.pm	2012-04-27 11:16:42 UTC (rev 11845)
@@ -62,9 +62,9 @@
         # update user, undelete (checked to see if already expunged earlier)
         LJ::update_user($fromu, { raw => "journaltype='R', statusvis='R', statusvisdate=NOW()" });
 
-        LJ::infohistory_add($fromu, 'journaltype', $org_journaltype);
-        LJ::infohistory_add($fromu, 'statusvis', $org_statusvis);
-        LJ::infohistory_add($fromu, 'renamedto', $org_renamedto);
+        LJ::User::InfoHistory->add( $fromu, 'journaltype', $org_journaltype );
+        LJ::User::InfoHistory->add( $fromu, 'statusvis',   $org_statusvis );
+        LJ::User::InfoHistory->add( $fromu, 'renamedto',   $org_renamedto );
         LJ::statushistory_add($fromu, $remote, 'user_redirect_add', "Redirecting to '$arg'");
 
         return $self->print("Redirection added from '$from' to '$arg'");
@@ -83,9 +83,9 @@
         # update user, set deleted
         LJ::update_user($fromu, { raw => "journaltype='$arg', statusvis='V', statusvisdate=NOW()" });
 
-        LJ::infohistory_add($fromu, 'journaltype', $org_journaltype);
-        LJ::infohistory_add($fromu, 'statusvis', $org_statusvis);
-        LJ::infohistory_add($fromu, 'renamedto', $org_renamedto);
+        LJ::User::InfoHistory->add( $fromu, 'journaltype', $org_journaltype );
+        LJ::User::InfoHistory->add( $fromu, 'statusvis',   $org_statusvis );
+        LJ::User::InfoHistory->add( $fromu, 'renamedto',   $org_renamedto );
         LJ::statushistory_add($fromu, $remote, 'user_redirect_removed');
 
         return $self->print("Redirection from '$from' removed.");

Modified: trunk/cgi-bin/LJ/Sponsored/User.pm
===================================================================
--- trunk/cgi-bin/LJ/Sponsored/User.pm	2012-04-27 11:04:44 UTC (rev 11844)
+++ trunk/cgi-bin/LJ/Sponsored/User.pm	2012-04-27 11:16:42 UTC (rev 11845)
@@ -154,12 +154,18 @@
     local $dbr->{RaiseError} = 1;    
 
     my $check_all_current_emails = $dbr->prepare("SELECT count(*) FROM email WHERE email = ? AND userid != ?");
+
+    # TODO: change parts of it working with infohistory to using
+    # LJ::User::InfoHistory; this is not that important because
+    # LJ::Sponsored::* is not used at the time of writing,
+    # but still, database joins are suboptimal
     my $check_sponsored_validated = $dbr->prepare("SELECT count(*) FROM sup_sponsored_users s, user u, email e "
                                                   . "WHERE s.sponsorid = ? AND s.userid = u.userid AND s.userid = e.userid "
                                                   . "AND u.status = 'A' AND e.email = ?");
     my $find_last_validated = $dbr->prepare("SELECT h.userid, MAX(h.timechange) FROM sup_sponsored_users s, user u, infohistory h "
                                             . "WHERE s.sponsorid = ? AND s.userid = u.userid AND s.userid = h.userid "
                                             . "AND u.status != 'A' AND h.what = 'email' AND h.other = 'A' GROUP BY h.userid");
+
     my $check_last_validated = $dbr->prepare("SELECT count(*) FROM infohistory WHERE userid = ? AND timechange = ? AND oldvalue = ?");
 
     # Check, if $new_email is used by current set of sponsored users

Tags: ailyin, andy, ljcom, pm
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments