Friday, September 27, 2013

Developer Day #4 - Neo4j


Today we explain how we're using Neo4j to perform our spatial queries. That's where the real magic of Find-A-Record happens. Here's the most complicated query we discussed in the video:

start node = node:geom('withinDistance:[{lat},{lon},{rad}]')
MATCH node-[r:COV]-(col)
WHERE all( rel in r 

    WHERE rel.from >= {from} 
    AND rel.to <= {to} 
    AND rel.tag = {tag}
)
return col.cbid

This week we got clocked on the head by the 80/20 rule of software development (read more about that rule here). This is why we look exhausted in our video this week. Some of the fun details:
  • In Ubuntu's Upstart conf files, environment variables are not set on an exec command unless you add -l to the su command (ie, exec su -l -c "<command>" user >> output.log). This is because su runs in a non-login shell by default (See this article here, specifically the last couple of paragraphs). And non-login shells don't run /etc/profile.d/nodejs.sh to set the environment variables!
  • Know your network topology BEFORE you start making assumptions! We ended up with two separate APIs, a private one for the website and User information, and a public one for the actual Data. Problem is, we had some code already written that assumed 1 API. Silly us.
  • If you have a terminal session up and you are SSH'd into a server running nodemon, a 1 second network hiccup will freeze the connection in such a way that the server will not kill your terminal session but you will be disconnected by putty. Fun fun. "ps ax" and "kill" to the rescue.

No comments:

Post a Comment