Detect anomalies in user behavior using Rails and PostgreSQL