From d2db0f728572c6abdcd7c3d5ff3d9f59705af208 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Wed, 19 Sep 2012 15:59:45 +0200 Subject: [PATCH] Change session_search to get all sort parameters, so it can configure the correct sort at search time. This will make session_sort skip the re-search. Added debugging of the sort parameters in session_clear_set --- src/session.c | 9 +++++---- src/session.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/session.c b/src/session.c index 4a817a2..a2d4c99 100644 --- a/src/session.c +++ b/src/session.c @@ -638,6 +638,9 @@ static void session_clear_set(struct session *se, se->sorted_results->position = position; se->sorted_results->next = 0; + session_log(se, YLOG_DEBUG, "clear_set search_sort: field=%s increasing=%d position=%d configured", + sort_field, increasing, position); + se->reclist = reclist_create(se->nmem); } @@ -651,7 +654,6 @@ void session_sort(struct session *se, const char *field, int increasing, yaz_log(YLOG_LOG, "session_sort field=%s increasing=%d position=%d", field, increasing, position); /* see if we already have sorted for this critieria */ - /* TODO I do not see the point in saving all previous sorts. Dont we re-sort anyway ? */ for (sr = se->sorted_results; sr; sr = sr->next) { if (!strcmp(field, sr->field) && increasing == sr->increasing && sr->position == position) @@ -701,8 +703,7 @@ enum pazpar2_error_code session_search(struct session *se, const char *filter, const char *limit, const char **addinfo, - const char *sort_field, - int increasing) + struct reclist_sortparms *sp) { int live_channels = 0; int no_working = 0; @@ -723,7 +724,7 @@ enum pazpar2_error_code session_search(struct session *se, session_enter(se); se->settings_modified = 0; - session_clear_set(se, sort_field, increasing, 0); /* hardcoded position */ + session_clear_set(se, sp->name, sp->increasing, sp->type == Metadata_sortkey_position); relevance_destroy(&se->relevance); live_channels = select_targets(se, filter); diff --git a/src/session.h b/src/session.h index ea2cb01..45fdbb3 100644 --- a/src/session.h +++ b/src/session.h @@ -163,7 +163,7 @@ enum pazpar2_error_code session_search(struct session *s, const char *query, const char *maxrecs, const char *filter, const char *limit, const char **addinfo, - const char *sort_field, int increasing); + struct reclist_sortparms *sort_parm); struct record_cluster **show_range_start(struct session *s, struct reclist_sortparms *sp, int start, -- 1.7.10.4