X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fsession.c;h=4d64e327292f0deb7d17a4c121309e999afcb994;hb=3179097f17e360a9c61a87686680e5e6bfac2646;hp=4910ea9e956aa59f75a7b7207c8a05239c87b7c6;hpb=d0b84bb0535c50ec7b6b4650335c2dbe69c93e5e;p=pazpar2-moved-to-github.git diff --git a/src/session.c b/src/session.c index 4910ea9..4d64e32 100644 --- a/src/session.c +++ b/src/session.c @@ -146,7 +146,7 @@ void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num) } -static void add_facet(struct session *s, const char *type, const char *value) +void add_facet(struct session *s, const char *type, const char *value, int count) { int i; @@ -168,7 +168,9 @@ static void add_facet(struct session *s, const char *type, const char *value) = termlist_create(s->nmem, TERMLIST_HIGH_SCORE); s->num_termlists = i + 1; } - termlist_insert(s->termlists[i].termlist, value); + yaz_log(YLOG_DEBUG, "Session: facets for %s: %s (%d)", type, value, count); + + termlist_insert(s->termlists[i].termlist, value, count); } static xmlDoc *record_to_xml(struct session_database *sdb, const char *rec) @@ -434,7 +436,7 @@ void session_alert_watch(struct session *s, int what) session_watchfun fun; http_remove_observer(s->watchlist[what].obs); - fun = s->watchlist[what].fun; + fun = s->watchlist[what].fun; data = s->watchlist[what].data; /* reset watch before fun is invoked - in case fun wants to set @@ -444,6 +446,7 @@ void session_alert_watch(struct session *s, int what) s->watchlist[what].obs = 0; session_leave(s); + yaz_log(YLOG_DEBUG, "session_alert_watch: %d calling function: %p", what, fun); fun(data); } else @@ -507,6 +510,19 @@ int session_active_clients(struct session *s) return res; } +int session_is_preferred_clients_ready(struct session *s) +{ + struct client_list *l; + int res = 0; + + for (l = s->clients; l; l = l->next) + if (client_is_active_preferred(l->client)) + res++; + yaz_log(YLOG_DEBUG, "%p Session has %d active preferred clients.", s, res); + return res == 0; +} + + enum pazpar2_error_code search(struct session *se, const char *query, @@ -981,7 +997,10 @@ static int get_mergekey_from_doc(xmlDoc *doc, xmlNode *root, const char *name, if (!strcmp((const char *) n->name, "metadata")) { xmlChar *type = xmlGetProp(n, (xmlChar *) "type"); - if (!strcmp(name, (const char *) type)) + if (type == NULL) { + yaz_log(YLOG_FATAL, "Missing type attribute on metadata element. Skipping!"); + } + else if (!strcmp(name, (const char *) type)) { xmlChar *value = xmlNodeListGetString(doc, n->children, 1); if (value) @@ -1140,6 +1159,7 @@ static int ingest_to_cluster(struct client *cl, \param cl client holds the result set for record \param rec record buffer (0 terminated) \param record_no record position (1, 2, ..) + \param nmem working NMEM \retval 0 OK \retval -1 failure */ @@ -1371,22 +1391,23 @@ static int ingest_to_cluster(struct client *cl, (char *) value, ser_md->rank, ser_md->name); - // construct facets ... - if (ser_md->termlist) + // construct facets ... unless the client already has reported them + if (ser_md->termlist && !client_has_facet(cl, (char *) type)) { + if (ser_md->type == Metadata_type_year) { char year[64]; sprintf(year, "%d", rec_md->data.number.max); - add_facet(se, (char *) type, year); + add_facet(se, (char *) type, year, 1); if (rec_md->data.number.max != rec_md->data.number.min) { sprintf(year, "%d", rec_md->data.number.min); - add_facet(se, (char *) type, year); + add_facet(se, (char *) type, year, 1); } } else - add_facet(se, (char *) type, (char *) value); + add_facet(se, (char *) type, (char *) value, 1); } // cleaning up