Change termlist result to include also empty lists
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 19 Oct 2011 17:02:51 +0000 (19:02 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 19 Oct 2011 17:02:51 +0000 (19:02 +0200)
This makes it behave like previous release 1.6.3.

src/session.c
test/test_facets_11.res
test/test_facets_14.res
test/test_facets_17.res
test/test_facets_18.res
test/test_facets_24.res
test/test_facets_6.res

index 1be728f..388e94e 100644 (file)
@@ -1045,6 +1045,11 @@ void perform_termlist(struct http_channel *c, struct session *se,
     for (j = 0; j < num_names; j++)
     {
         const char *tname;
+        
+        wrbuf_puts(c->wrbuf, "<list name=\"");
+        wrbuf_xmlputs(c->wrbuf, names[j]);
+        wrbuf_puts(c->wrbuf, "\">\n");
+
         for (i = 0; i < se->num_termlists; i++)
         {
             tname = se->termlists[i].name;
@@ -1056,9 +1061,6 @@ void perform_termlist(struct http_channel *c, struct session *se,
                 if (p)
                 {
                     int i;
-                    wrbuf_puts(c->wrbuf, "<list name=\"");
-                    wrbuf_xmlputs(c->wrbuf, tname);
-                    wrbuf_puts(c->wrbuf, "\">\n");
                     for (i = 0; i < len && i < num; i++)
                     {
                         // prevent sending empty term elements
@@ -1075,19 +1077,15 @@ void perform_termlist(struct http_channel *c, struct session *se,
                                      p[i]->frequency);
                         wrbuf_puts(c->wrbuf, "</term>\n");
                     }
-                    wrbuf_puts(c->wrbuf, "</list>\n");
                 }
             }
         }
         tname = "xtargets";
         if (num_names > 0 && !strcmp(names[j], tname))
         {
-            wrbuf_puts(c->wrbuf, "<list name=\"");
-            wrbuf_xmlputs(c->wrbuf, tname);
-            wrbuf_puts(c->wrbuf, "\">\n");
             targets_termlist_nb(c->wrbuf, se, num, c->nmem);
-            wrbuf_puts(c->wrbuf, "</list>\n");
         }
+        wrbuf_puts(c->wrbuf, "</list>\n");
     }
     session_leave(se);
     nmem_destroy(nmem_tmp);
index 6045d02..aaf0155 100644 (file)
@@ -45,4 +45,6 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file
index f750176..37b5a75 100644 (file)
@@ -45,4 +45,6 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file
index 7765713..00e11f8 100644 (file)
@@ -45,4 +45,6 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file
index 7765713..00e11f8 100644 (file)
@@ -45,4 +45,6 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file
index 512b81f..598b204 100644 (file)
@@ -40,4 +40,6 @@
 <term><name>date8</name><frequency>20</frequency></term>
 <term><name>date9</name><frequency>10</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file
index f78c7dc..ebb8bb4 100644 (file)
@@ -30,4 +30,6 @@
 <term><name>1973</name><frequency>1</frequency></term>
 <term><name>1980</name><frequency>1</frequency></term>
 </list>
+<list name="medium">
+</list>
 </termlist>
\ No newline at end of file