[ckan-dev] Activity streams issue with deleted objects
sean.hammond at okfn.org
Sun Feb 5 19:33:17 GMT 2012
Hey, I just wanted to flag up this issue I'm having with the activity
If you delete an object such as a dataset, previous activity stream
activities such as "Alice updated the dataset Foo" etc. still hyperlink
to the deleted dataset. If it's a dataset for example the link takes you
to a page where you can still see the 'deleted' dataset. If it's a
resource the link might take you to a 404.
I'm not sure how important this is or how to fix it.
I think the activity streams logic action functions such as
user_activity_list() etc. are probably the right place to fix this. The
function gets a list of Activity objects from the database, and each
Activity object holds the ID of the object of the activity (the Package
or Resource etc.) But the object which the ID identifies could be of
several types (Package, Resource...) so you can't simply do something
like model.Package.get(id) to find out if the object still exists. You
would have to switch on the activity_type field of the Activity object,
if activity.activity_type in ('new package', 'changed package',
obj = model.Package.get(id)
elif activity.activity_type in ('new resource', 'changed resource',
obj = model.Resource.get(id)
This doesn't seem like a very good solution.
The only other thing I can think of so far is to look for the most
recent activity in the activities table for that object ID and see if
the state of the object at the time of that activity (recorded in the
activities table row) was 'deleted'.
Is there a better way around this?
More information about the ckan-dev