Store the task id of a processing action in the database.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 25 Jul 2011 04:12:46 +0000 (23:12 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 25 Jul 2011 04:12:46 +0000 (23:12 -0500)
mediagoblin/db/migrations.py
mediagoblin/db/models.py
mediagoblin/submit/views.py

index 6a8ebcf920d49ee1f64a722f7ca6184bf1af9781..797d39de1010373b04c8cd7293fdaafaacb50e69 100644 (file)
@@ -52,3 +52,15 @@ def mediaentry_mediafiles_main_to_original(database):
         document['media_files']['original'] = original
 
         collection.save(document)
+
+
+@RegisterMigration(3)
+def mediaentry_add_queued_task_id(database):
+    """
+    Add the 'queued_task_id' field for entries that don't have it.
+    """
+    collection = database['media_entries']
+    collection.update(
+        {'queued_task_id': {'$exists': False}},
+        {'$set': {'queued_task_id': None}},
+        multi=True)
index bad15acad7c8ab595bdbeb1450097049565b174a..e97dc5376d6ddd48a163c037c2d2a77d62d3e77c 100644 (file)
@@ -162,6 +162,8 @@ class MediaEntry(Document):
        queued for processing.  This is stored in the mg_globals.queue_store
        storage system.
 
+     - queued_task_id: celery task id.  Use this to fetch the task state.
+
      - media_files: Files relevant to this that have actually been processed
        and are available for various types of display.  Stored like:
          {'thumb': ['dir1', 'dir2', 'pic.png'}
@@ -190,6 +192,7 @@ class MediaEntry(Document):
         # For now let's assume there can only be one main file queued
         # at a time
         'queued_media_file': [unicode],
+        'queued_task_id': unicode,
 
         # A dictionary of logical names to filepaths
         'media_files': dict,
index 1848f5e58aa0844f4963d626ce26925ce4749e6d..f19bf22e29bcc2a8578e5e069c6dc4c71514f028 100644 (file)
@@ -84,7 +84,8 @@ def submit_start(request):
             entry.save(validate=True)
 
             # queue it for processing
-            process_media_initial.delay(unicode(entry['_id']))
+            result = process_media_initial.delay(unicode(entry['_id']))
+            entry['queued_task_id'] = result.task_id
 
             add_message(request, SUCCESS, 'Woohoo! Submitted!')