[ckan-dev] Activity streams issue with deleted objects

David Raznick kindly at gmail.com
Mon Feb 6 01:03:08 UTC 2012


Hello,

I think it should not matter too much for now.  Deletions do not
happen too often and there is a justification for the links not
working once it has been deleted.

It happens all the time in other kind of feeds, so its not that bad.

Nonetheless, my take on the solution would be to add a flag to the
activity/activity details tables to say that the link is no longer
valid.  This flag could be populated on resource/package delete.  This
way you will only have to update the activity and the activity details
using the guid and this would happen when saving.  It seems a bit
wasteful to keep checking when 'viewing' the stream especially
considering how many tables you could have to look through as you
said.
Also this flag could also be easily populated by a simple background task/ cron.

All in all though doing any of these seems like a bit of a waste.

Thanks

David


On Sun, Feb 5, 2012 at 7:33 PM, Sean Hammond <sean.hammond at okfn.org> wrote:
> Hey, I just wanted to flag up this issue I'm having with the activity
> streams:
>
> http://trac.ckan.org/ticket/1743
>
> 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, like:
>
>    if activity.activity_type in ('new package', 'changed package', 'deleted
> package'):
>        obj = model.Package.get(id)
>    elif activity.activity_type in ('new resource', 'changed resource',
> 'deleted resource'):
>        obj = model.Resource.get(id)
>    elif ...:
>        ...
>
> 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?
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev




More information about the ckan-dev mailing list