simplify VisitModel.create
Opened this issue · 0 comments
jaredhirsch commented
When we create a visit, we lazily create a user-page in postgres. This is really hairy SQL, and while it's good SQL style to be declarative, not imperative, it doesn't work well with elasticsearch: we can't tell if the page already existed, or was just created, so, when we go on to add the new user-page into elasticsearch, elasticsearch errors if the page already exists.
The best fix here is to simplify visit creation, moving the user-page existence check into the user-page model. This gives us two simple SQL queries instead of one huge crazy one, and lets us avoid elasticsearch errors.