From 6b9ee0ca13b99ee20f9d0c680a950c6a7494a5a0 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 24 Jul 2011 23:12:46 -0500 Subject: [PATCH] Store the task id of a processing action in the database. --- mediagoblin/db/migrations.py | 12 ++++++++++++ mediagoblin/db/models.py | 3 +++ mediagoblin/submit/views.py | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 6a8ebcf9..797d39de 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -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) diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index bad15aca..e97dc537 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -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, diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index 1848f5e5..f19bf22e 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -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!') -- 2.25.1