Wednesday, February 18, 2009

Ratings * 100

I was thinking that the rating returned by simpleDB were a sum of all the ratings, so that the average rating could be found by dividing simpleDB's rating by the rating count. I think I was wrong. It seems that simpleDB's rating is the rating reported to the client times 100.

/list/recent in under 70 lines

I am using Sinatra (thanks for the tip Devlin) to make the http endpoints. It is neat how you can get a RESTful interface with such little code.
On to /list/popular, which should be less than 70 lines, if I've listened to anything I've been taught about avoiding code duplication.

Friday, February 6, 2009

POSTing image conntinued...

rest-client:
As a poster on a page I linked to mentioned, I can't figure out how to make rest-client post in multipart.

curb (ruby bindings for libcurl):
Rails was segfaulting.

curl on the command line:
A little hacky, but it works. I actually had a picture show up in the approval queue!

Also, I didn't change some hard coded image id's for the rate submitter and comment submitter, so that explains why rating would get back a number successfully, but on a refresh it wouldn't persist.

Look at tomorrow for multipart...

http://redwriteshere.com/tag/curb/

Thursday, February 5, 2009

Working on Webserver Layer

I was getting an "InvalidAuthenticityToken" exception when trying to post to my end point for the rating widget. I found a thread with Google on Ruby Forum that I think will help.

I thought the webserver was supposed to return json from /ratesubmit, but really it just returns a number, which is the rating.

For some reason, my rating seems to work, but when I reload the page, it doesn't seem to persist. I've tried posting to the reference app server and the load balanced app server.

To get things in config/initializers to work, restarting WEBrick is helpful.

POSTing a file in ruby is a fun challenge:
http://stackoverflow.com/questions/184178/ruby-how-to-post-a-file-via-http-as-multipartform-data
http://snippets.dzone.com/posts/show/5165
http://curb.rubyforge.org/

Couldn't get curb or rest_client to work..

A Couple Fixed Bugs

I found a couple bugs a while ago that I understand have already been fixed:
  • If there was only one tag, the app server would return a string representing the tag, rather than array of size one containing the tag. Not hard to code around, but I believe it was inconsistent with the API.
  • The comments on the reference web server implementation seemed to always be from the person who submitted the picture, rather than who submitted the comments
I know this is old news, but I didn't get around to posting it before.