]> git.parisson.com Git - telemeta-data.git/commitdiff
migration: print collections:copy stats
authorolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Thu, 23 Apr 2009 18:48:22 +0000 (18:48 +0000)
committerolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Thu, 23 Apr 2009 18:48:22 +0000 (18:48 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@86 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/import/migration/tasks/collections.py

index 2bc45e94c20810935ee232a986f4707e0537cc45..eff2b3ba349b44a4856750cd42bc609b62048dfa 100644 (file)
@@ -86,6 +86,7 @@ class CollectionsCopyMigrator(DataMigrator):
 
         self.src_cursor.execute("SELECT COUNT(*) FROM %s.Support" %  self.src_db_name)
         count = self.src_cursor.fetchone()[0]
+        self.stats = { 'total': count, 'imported': 0, 'ignored': 0}
 
         for offset in range(0, count):
             query = "INSERT INTO %s.media_collections (\n  %s\n)\n" \
@@ -98,12 +99,14 @@ class CollectionsCopyMigrator(DataMigrator):
 
             try:
                 self.target_cursor.execute(query)
+                self.stats['imported'] += 1
             except IntegrityError, e:
                 (errno, errmsg) = e
                 if errno == DUP_ENTRY:
                     self.src_cursor.execute("SELECT Cote FROM %s.Support LIMIT %d, 1" % (self.src_db_name, offset))
                     id = self.src_cursor.fetchone()[0]
                     print "Collection %s not imported: %s" % (id, errmsg)
+                    self.stats['ignored'] += 1
                 else:
                     raise e
 
@@ -163,6 +166,8 @@ class CollectionsEnumMigrator(DataMigrator):
                                                        "WHERE code = %s", (idrow[0], code))
                             if self.target_cursor.rowcount > 1:
                                 raise Exception("Updated more than one row, this shouldn't happen..")
+                            elif not self.target_cursor.rowcount:
+                                print "Can't find migrated collection: %s" % code
                         else:
                             print "Can't find value '%s' in %s" % (value, enum_tables[i])