[Ruby-aws-develop] Turk notifications
Steve Quezadas
steve at thestever.net
Tue Dec 2 19:15:07 EST 2008
Thanks. Once I brush up on my ruby skills, I'll try to donate some code
to add a helper function. I'm still a ruby newbie (probably by your
standards).
- Steve
David J Parrott wrote:
> Hi Steve,
>
> RubyAWS doesn't currently have a helper function for simplifying event
> notifications. What you're getting back is a hash, which should be
> perfectly usable. The only complicated part is the
> "Event.1.Attribute" vs "Event.2.Attribute" part. That's the standard
> way of encoding a nested hash as a single-level hash.
>
> {XXX.1.YYY => ZZZ} maps to { XXX => [ {YYY => ZZZ} ] }
>
> In my own Rails code that processes events, i typically do something
> like this:
>
> i=1
> while !params["Event.#{i}.EventType"].nil?
> event_type = params["Event.#{i}.EventType"]
> hit_id = params["Event.#{i}.HITId"]
> case event_type
> when "HITReviewable"
> # do stuff
> when "AssignmentSubmitted"
> assignment_id = params["Event.#{i}.AssignmentId"]
> # do stuff
> end
> end
>
> i'm sure it wouldn't be to hard to write some code that converted the
> single-level hash into a multi-level hash as well, but i don't have
> the time right this moment, and i'm not sure it would really help that
> much.
>
> Good luck, and if you still need help, let the list know.
>
> -David
>
>
> On Dec 1, 2008, at 10:45 PM, Steve Quezadas wrote:
>
>> I set up mechanical turk for notifications when a HIT gets completed.
>> When it happens, the amazon server contacts my webserver with a GET
>> request.
>>
>> This is probably a basic question, but what aws method do I use to
>> process the incoming GET request? It looks like this (I unencoded it
>> for your reading convenience):
>> Event.1.HITId => 12345678901234567890
>> Event.1.HITTypeId => 09876543210987654321
>> Event.1.AssignmentId => 1234567890123456789012345678901234567890
>> Event.1.EventType => AssignmentSubmitted
>> Event.1.EventTime => 2008-11-30T01:33:03Z
>> Event.2.HITId => 12345678901234567890
>> Event.2.HITTypeId => 09876543210987654321
>> Event.2.AssignmentId => 1234567890123456789012345678900987654321
>> Event.2.EventType => AssignmentSubmitted
>> Event.2.EventTime => 2008-11-30T01:33:03Z
>> Version => 2006-05-05
>> Signature => xxxxxxxxxxxxxxx
>> Timestamp => 2008-11-30T01:33:07Z
>> action => receive_message
>> method => Notify
>> controller => ask
>>
>> SimplifyAnswer doesn't seem to work. Anyone know the answer?
>>
>> - Steve
>> _______________________________________________
>> Ruby-aws-develop mailing list
>> Ruby-aws-develop at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/ruby-aws-develop
>
> _______________________________________________
> Ruby-aws-develop mailing list
> Ruby-aws-develop at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ruby-aws-develop
More information about the Ruby-aws-develop
mailing list