fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-03-29 08:48 am

[dw-free] Imports show up as "aborted" when we're processing previous imports

[commit: http://hg.dwscoalition.org/dw-free/rev/7cfe01b86856]

http://bugs.dwscoalition.org/show_bug.cgi?id=4066

Tell the user we're processing their previous imports if the import status
is aborted because we've already got that in queue

Patch by [personal profile] fu.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/Widget/ImportStatus.pm
--------------------------------------------------------------------------------
diff -r d6c8614818e0 -r 7cfe01b86856 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Thu Mar 29 16:27:49 2012 +0800
+++ b/bin/upgrading/en.dat	Thu Mar 29 16:50:36 2012 +0800
@@ -4739,6 +4739,8 @@
 
 widget.importstatus.item.lj_verify=Verifying username/password
 
+widget.importstatus.processingprevious=- we're currently processing your previous import request
+
 widget.importstatus.refresh=Refresh
 
 widget.importstatus.status.aborted=Aborted
diff -r d6c8614818e0 -r 7cfe01b86856 cgi-bin/LJ/Widget/ImportStatus.pm
--- a/cgi-bin/LJ/Widget/ImportStatus.pm	Thu Mar 29 16:27:49 2012 +0800
+++ b/cgi-bin/LJ/Widget/ImportStatus.pm	Thu Mar 29 16:50:36 2012 +0800
@@ -38,6 +38,22 @@
         $ret .= "<table summary='' width='100%' class='importer-status'>";
 
         my $import_in_progress = 0;
+
+        my $item_to_funcname = {
+            lj_bio => 'DW::Worker::ContentImporter::LiveJournal::Bio',
+            lj_tags => 'DW::Worker::ContentImporter::LiveJournal::Tags',
+            lj_entries => 'DW::Worker::ContentImporter::LiveJournal::Entries',
+            lj_comments => 'DW::Worker::ContentImporter::LiveJournal::Comments',
+            lj_userpics => 'DW::Worker::ContentImporter::LiveJournal::Userpics',
+            lj_friends => 'DW::Worker::ContentImporter::LiveJournal::Friends',
+            lj_friendgroups => 'DW::Worker::ContentImporter::LiveJournal::FriendGroups',
+            lj_verify => 'DW::Worker::ContentImporter::LiveJournal::Verify',
+        };
+
+
+        my $dbr;
+        my $funcmap;
+        my $dupect = 0;
         foreach my $importid ( sort { $b <=> $a } keys %$items ) {
             my $import_item = $items->{$importid};
 
@@ -64,7 +80,29 @@
                     $status .= $class->ml( "widget.importstatus.status.$i->{status}.$item" );
                 } else {
                     $status .= $class->ml( "widget.importstatus.status.$i->{status}" );
+
+                    if ( $i->{status} eq "aborted" ) {
+                        unless ( $dbr ) {
+                            # do manual connection
+                            my $db = $LJ::THESCHWARTZ_DBS[0];
+                            $dbr = DBI->connect( $db->{dsn}, $db->{user}, $db->{pass} );
+                        }
+
+                        if ( $dbr ) {
+                            # get the ids for the function map
+                            $funcmap ||= $dbr->selectall_hashref( 'SELECT funcid, funcname FROM funcmap', 'funcname' );
+
+                            $dupect = $dbr->selectrow_array(
+                                q{SELECT COUNT(*) from job
+                                    WHERE funcid  = ?
+                                      AND uniqkey = ? },
+                                undef, $funcmap->{$item_to_funcname->{$item}}->{funcid}, join( "-", ( $item, $u->id ) )
+                            );
+                        }
+                    }
                 }
+
+                $status .= " " . $class->ml( "widget.importstatus.processingprevious" ) if $dupect;
                 $status .= "</span>";
 
                 $ret .= "<tr>";
--------------------------------------------------------------------------------