From steve at thestever.net Tue Dec 2 01:45:51 2008 From: steve at thestever.net (Steve Quezadas) Date: Mon, 01 Dec 2008 22:45:51 -0800 Subject: [Ruby-aws-develop] Turk notifications Message-ID: <4934D99F.5020305@thestever.net> 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 From valthon at nothlav.net Tue Dec 2 18:59:19 2008 From: valthon at nothlav.net (David J Parrott) Date: Tue, 2 Dec 2008 15:59:19 -0800 Subject: [Ruby-aws-develop] Turk notifications In-Reply-To: <4934D99F.5020305@thestever.net> References: <4934D99F.5020305@thestever.net> Message-ID: <4A8345E4-867D-44D9-AEC9-8C8B2787FC00@nothlav.net> 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 From steve at thestever.net Tue Dec 2 19:15:07 2008 From: steve at thestever.net (Steve Quezadas) Date: Tue, 02 Dec 2008 16:15:07 -0800 Subject: [Ruby-aws-develop] Turk notifications In-Reply-To: <4A8345E4-867D-44D9-AEC9-8C8B2787FC00@nothlav.net> References: <4934D99F.5020305@thestever.net> <4A8345E4-867D-44D9-AEC9-8C8B2787FC00@nothlav.net> Message-ID: <4935CF8B.10201@thestever.net> 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