From: Adam Dickmeiss Date: Tue, 13 Dec 2011 13:35:42 +0000 (+0100) Subject: Fix termlist for omitting name parameter X-Git-Tag: v1.6.7~21^2~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=8b22d0dda50f29c25ec63e749b8c32738530498c;p=pazpar2-moved-to-github.git Fix termlist for omitting name parameter Command termlist without name parameter should now return all available termlist entries. Note that if name is given and that refers to a non-existing termlist entry, no list is generated. Previously an empty list was generated. --- diff --git a/src/session.c b/src/session.c index 9706e0e..d388016 100644 --- a/src/session.c +++ b/src/session.c @@ -1058,8 +1058,10 @@ void perform_termlist(struct http_channel *c, struct session *se, char **names; int num_names = 0; - if (name) - nmem_strsplit(nmem_tmp, ",", name, &names, &num_names); + if (!name) + name = "*"; + + nmem_strsplit(nmem_tmp, ",", name, &names, &num_names); session_enter(se); @@ -1067,17 +1069,18 @@ void perform_termlist(struct http_channel *c, struct session *se, { const char *tname; - wrbuf_puts(c->wrbuf, "wrbuf, names[j]); - wrbuf_puts(c->wrbuf, "\">\n"); - for (i = 0; i < se->num_termlists; i++) { tname = se->termlists[i].name; - if (num_names > 0 && !strcmp(names[j], tname)) + if (!strcmp(names[j], tname) || !strcmp(names[j], "*")) { struct termlist_score **p = 0; int len; + + wrbuf_puts(c->wrbuf, "wrbuf, tname); + wrbuf_puts(c->wrbuf, "\">\n"); + p = termlist_highscore(se->termlists[i].termlist, &len); if (p) { @@ -1099,14 +1102,19 @@ void perform_termlist(struct http_channel *c, struct session *se, wrbuf_puts(c->wrbuf, "\n"); } } + wrbuf_puts(c->wrbuf, "\n"); } } tname = "xtargets"; - if (num_names > 0 && !strcmp(names[j], tname)) + if (!strcmp(names[j], tname) || !strcmp(names[j], "*")) { + wrbuf_puts(c->wrbuf, "wrbuf, tname); + wrbuf_puts(c->wrbuf, "\">\n"); + targets_termlist_nb(c->wrbuf, se, num, c->nmem); + wrbuf_puts(c->wrbuf, "\n"); } - wrbuf_puts(c->wrbuf, "\n"); } session_leave(se); nmem_destroy(nmem_tmp); diff --git a/test/test_facets.urls b/test/test_facets.urls index af9d74a..805ab95 100644 --- a/test/test_facets.urls +++ b/test/test_facets.urls @@ -11,7 +11,7 @@ http://localhost:9763/search.pz2?session=1&command=bytarget http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium http://localhost:9763/search.pz2?session=1&command=search&query=8+and+computer http://localhost:9763/search.pz2?session=1&command=show&block=1 -http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium +http://localhost:9763/search.pz2?session=1&command=termlist http://localhost:9763/search.pz2?session=1&command=search&query=6+and+computer http://localhost:9763/search.pz2?session=1&command=show http://localhost:9763/search.pz2?session=1&command=termlist&name=xtargets%2Cauthor%2Csubject%2Cdate%2Cmedium diff --git a/test/test_facets_11.res b/test/test_facets_11.res index aaf0155..6045d02 100644 --- a/test/test_facets_11.res +++ b/test/test_facets_11.res @@ -45,6 +45,4 @@ date820 date910 - - \ No newline at end of file diff --git a/test/test_facets_14.res b/test/test_facets_14.res index 37b5a75..f750176 100644 --- a/test/test_facets_14.res +++ b/test/test_facets_14.res @@ -45,6 +45,4 @@ date820 date910 - - \ No newline at end of file diff --git a/test/test_facets_17.res b/test/test_facets_17.res index 00e11f8..7765713 100644 --- a/test/test_facets_17.res +++ b/test/test_facets_17.res @@ -45,6 +45,4 @@ date820 date910 - - \ No newline at end of file diff --git a/test/test_facets_18.res b/test/test_facets_18.res index 00e11f8..7765713 100644 --- a/test/test_facets_18.res +++ b/test/test_facets_18.res @@ -45,6 +45,4 @@ date820 date910 - - \ No newline at end of file diff --git a/test/test_facets_24.res b/test/test_facets_24.res index 598b204..512b81f 100644 --- a/test/test_facets_24.res +++ b/test/test_facets_24.res @@ -40,6 +40,4 @@ date820 date910 - - \ No newline at end of file diff --git a/test/test_facets_6.res b/test/test_facets_6.res index ebb8bb4..f78c7dc 100644 --- a/test/test_facets_6.res +++ b/test/test_facets_6.res @@ -30,6 +30,4 @@ 19731 19801 - - \ No newline at end of file