changeset 257:75b81da8d7a5

convert the feed entry timestamps to arango compatible date strings in migration
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:38:41 +0100
parents f79be01821c4
children 4ca1fac32dde
files migrate_couch_to_arango.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/migrate_couch_to_arango.py	Wed Jan 30 07:11:10 2019 +0100
+++ b/migrate_couch_to_arango.py	Tue Mar 12 02:38:41 2019 +0100
@@ -34,6 +34,12 @@
     date_string = couch_date.strftime('%Y-%m-%dT%H:%M:%S.000')
     arango_doc[key] = date_string
 
+def convert_date_tuple(couch_doc, arango_doc, key):
+    tuple = couch_doc[key]
+    couch_date = datetime(*tuple)
+    date_string = couch_date.strftime('%Y-%m-%dT%H:%M:%S.000')
+    arango_doc[key] = date_string
+
 def migrate_rest(document):
     if document['_id'].startswith('_design'):
         return
@@ -47,12 +53,14 @@
             migrate_preferences(document)
         else:
             print('how to migrate ' + document['_id'])
-    except KeyError:
+    except KeyError as err:
             print('**** migrate error ' + str(document))
 
 def migrate_feed_entry(couch_doc):
     arango_doc = arango_feed_entry.createDocument()
     copy(couch_doc, arango_doc)
+    convert_date_tuple(couch_doc, arango_doc, 'create_timestamp')
+    convert_date_tuple(couch_doc, arango_doc, 'updated')
     feed_id = arango_doc['feed']
     feed_id = feed_mapping[feed_id]
     arango_doc['feed'] = feed_id