Skip to content

Commit 3c31d88

Browse files
committed
fix: remove sort parameter and add client-side sorting for organizations
- Remove sort parameter from ckan_organization_list (causes 500 error) - Add client-side sorting by package_count descending - Simplify parameters to: all_fields, limit, response_format - Fix: organizations now sorted by dataset count client-side
1 parent 2fb8669 commit 3c31d88

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

web-gui/public/index.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,14 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
619619
620620
CRITICAL RULES FOR TOOL SELECTION:
621621
1. If user asks about ORGANIZATIONS (like "which organizations", "organizations with most datasets", "list organizations"):
622-
→ Use ckan_organization_list with all_fields=true and sort="package_count desc"
622+
→ Use ckan_organization_list with ONLY these parameters:
623+
{
624+
"server_url": "CKAN_SERVER",
625+
"all_fields": true,
626+
"limit": 100,
627+
"response_format": "json"
628+
}
629+
Do NOT use sort parameter - results will be sorted client-side by package_count
623630
624631
2. If user asks about DATASETS (like "find datasets about X", "datasets on topic Y"):
625632
→ Use ckan_package_search or ckan_find_relevant_datasets
@@ -638,7 +645,7 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
638645
}
639646
}
640647
641-
Always include server_url parameter.
648+
Always include server_url and response_format="json".
642649
Use conversation context to refine queries.`;
643650

644651
const contents = [
@@ -775,7 +782,15 @@ <h1 class="serif text-4xl md:text-5xl mb-2 gradient-text">
775782
// Handle different tool types
776783
if (tool.includes("organization")) {
777784
// Organization tools
778-
const items = data.results || data || [];
785+
let items = data.results || data || [];
786+
787+
// Sort by package_count descending (client-side)
788+
items = items.sort((a, b) => {
789+
const countA = a.package_count || 0;
790+
const countB = b.package_count || 0;
791+
return countB - countA;
792+
});
793+
779794
const summary = document.createElement("p");
780795
summary.className = "text-sm font-medium mb-1";
781796
summary.style.color = "var(--primary)";

0 commit comments

Comments
 (0)