don't insert null organizations in view
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 11 Jan 2013 12:13:46 +0000 (13:13 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 11 Jan 2013 12:13:46 +0000 (13:13 +0100)
angular-server.pl

index 29db13a..458337a 100755 (executable)
@@ -213,10 +213,12 @@ get '/:database/_design/:design/_view/:view' => sub {
                                organizations => {
                                        map    => q| function(doc) {
 if ( doc.user.organization != '' ) {
-  emit(doc.user.organization, 1);
+  if ( doc.user.organization )
+    emit(doc.user.organization, 1);
   if ( doc.user.persons ) {
     doc.user.persons.forEach( function(person) {
-      emit(person.organization, 1);
+      if ( person.organization )
+        emit(person.organization, 1);
     });
   }
 }
@@ -247,7 +249,9 @@ hook after_dispatch => sub {
 
        return if $self->res->headers->header('ETag');
 
-       my $our_etag = Mojo::ByteStream->new($body)->md5_sum;
+warn "## body $body";
+
+       my $our_etag = Mojo::ByteStream->new($body . $VERSION)->md5_sum;
        $self->res->headers->header('ETag' => $our_etag);
 
        my $browser_etag = $self->req->headers->header('If-None-Match');