[ckan-changes] [okfn/ckan] cb866b: Get a package's groups from the member table

GitHub noreply at github.com
Fri Mar 8 16:45:54 UTC 2013


  Branch: refs/heads/get_package_groups_from_member_table
  Home:   https://github.com/okfn/ckan
  Commit: cb866bc5bc97e8bb3cf766ae3542203fbad33ab9
      https://github.com/okfn/ckan/commit/cb866bc5bc97e8bb3cf766ae3542203fbad33ab9
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2013-03-08 (Fri, 08 Mar 2013)

  Changed paths:
    M ckan/lib/dictization/model_dictize.py

  Log Message:
  -----------
  Get a package's groups from the member table

Get a package's groups from the member table, not the member_revision
table.

After migrating a CKAN 1.3 database to CKAN 2.0, all of the group pages
showed no packages. On investigagin, I found:

group_show() would report "num_packages": 0 for a group, but under
"packages" there would be a non-empty list of packages.

package_show() for those same packages would show "groups": [].

Solr search queries would return no packages for the groups.

So the various ways of getting a count or list of a group's packages or
a package's groups were contradicting eachother.

The reason was that the member table in the database contained NULL for
the revision_id column for every row. Whether NULL should have been in
this column, or how it got there, I don't know. (Perhaps this is a bug
in the database migration scripts.)

When finding a group's list of packages, group_dictize() looks at the
member table, so it was finding the packages no problem.

But when finding a package's list of groups, package_dictize() does a
query on the member_revision table, not on the member table. Since in
this migrated database, the member table rows do not seem to have any
member_revisions, it was finding no groups for a package.

Since it's package dicts, not groups, that get indexed in Solr, each package
was indexed with no groups, and so Solr queries for packages in a group
returned 0.

This commit changes package_dictize() to use the member table not the
member_revision table to find a package's groups. After making this
change, I was able to rebuild the solr search index and my packages
reappeared on the group pages.





More information about the ckan-changes mailing list