Ticket #2230 (closed refactor: fixed)

Opened 2 years ago

Last modified 2 years ago

Tidy up of search facets code duplication

Reported by: seanh Owned by:
Priority: awaiting triage Milestone: ckan-v1.7
Component: ckan Keywords:
Cc: Repository: ckan
Theme: none

Description (last modified by seanh) (diff)

Because of a clash between two development branches there is some duplication of code to do with code facets (note: at the time of writing the code duplication exists only on the feature-1821-multilingual-extension branch, but this will be merged into master at some point):

The package_search() function is adding the search facets to the search results twice with two different data structures, with keys "facets" and "new_facets". It should be reduced to just the new facets (with the key changed to "facets").

Also the group and package controllers are adding both facets and new_facets to the context, should be new_facets only (but renamed to facets).

The facet_items() function in helpers.py should be removed, it uses the old facets structure and shouldn't be needed anymore with the new facets structure.

In facets.html, facet_sidebar() should be removed as it uses the old facets structure and facet_div() implements the same functionality but uses the new facets.

In facets.html, facet_list_items() will have to be updated to not use the facet_items() helper and to use the new facets structure instead.

Anywhere that "new_facets" appears it will have to be changed to "facets" (e.g. in the ckanext/multilingual/plugin.py.

This is the merge commit that introduced the duplication: https://github.com/okfn/ckan/commit/1153aa876f54c22289e460aeececea22d1d4d51d

This is the earlier commit where the search facets were refactored: https://github.com/okfn/ckan/commit/3970e52008b75933fda1be1d488bed2578d98c9c

Change History

comment:1 Changed 2 years ago by seanh

  • Type changed from enhancement to refactor
  • Description modified (diff)

comment:2 Changed 2 years ago by seanh

  • Description modified (diff)

comment:3 Changed 2 years ago by icmurray

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.