I used resource_show in CKAN 2.7.3 API docs to get metadata from specific resources. In my tracking_summary table, I have some resource which has tracking number larger than 0. However, when I use resource_show with {'include_tracking': True}, it shows both recent and total are 0.
My resource record in tracking_summary table looks like:
url | running_total | recent_views
-----------------------------------------------------------------------------------------------------------------+---------------+--------------
/dataset/d5cd38f4-03df-450e-9eb8-4967bc9741da/resource/844625fb-80a9-445c-85e7-5be8f10ec57b/download/test.csv | 1 | 1
I verified that I have already ran the command of paster tracking update and paster search-index rebuild. I don't know what am I missing now.
I found out the cause. If we look at the the
urlwe stored intracking_summarytable, it does not contain the http schema and domain:http://example.ckan.com. However if we are querying a resource fromresourcetable, theurlwill contain the full http url. Also, when you tried to callresource_showAPI with{'include_tracking': True}in your application, theget_for_resource(cls, url)inTrackingmodel will refer to the fullurlinstead of the partial one. So if we store the partial one, theget_for_resourcewill fail at the linedata = obj.filter_by(url=url).order_by(text('tracking_date desc')).first(). Therefore, when we save resource url intracking_summary, we should store the full one such as:http://example.ckan.com/dataset/<package_id>/resource/<resource_id>/<file_name>.