From: root Date: Tue, 24 Jun 2014 06:38:04 +0000 Subject: fix copy pasta error X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-dga-stats.git&a=commitdiff&h=c2e34670f1ad99175d32ee1e71e768490d5f5b44 --- fix copy pasta error --- --- a/ckanext/dga_stats/controller.py +++ b/ckanext/dga_stats/controller.py @@ -12,7 +12,6 @@ c.top_rated_packages = stats.top_rated_packages() c.most_edited_packages = stats.most_edited_packages() c.largest_groups = stats.largest_groups() - c.top_tags = stats.top_tags() c.top_package_owners = stats.top_package_owners() c.summary_stats = stats.summary_stats() c.activity_counts = stats.activity_counts() --- a/ckanext/dga_stats/stats.py +++ b/ckanext/dga_stats/stats.py @@ -72,6 +72,7 @@ def by_org(cls, limit=10): connection = model.Session.connection() res = connection.execute("select package.owner_org, package.private, count(*) from package \ + inner join (select distinct package_id from resource_group inner join resource on resource.resource_group_id = resource_group.id) as r on package.id = r.package_id \ inner join \"group\" on package.owner_org = \"group\".id \ where package.state='active'\ group by package.owner_org,\"group\".name, package.private \ @@ -107,6 +108,7 @@ def top_active_orgs(cls, limit=10): connection = model.Session.connection() res = connection.execute("select package.owner_org, count(*) from package \ + inner join (select distinct package_id from resource_group inner join resource on resource.resource_group_id = resource_group.id) as r on package.id = r.package_id \ inner join \"group\" on package.owner_org = \"group\".id \ inner join (select distinct object_id from activity where activity.timestamp > (now() - interval '60 day')) \ latestactivities on latestactivities.object_id = package.id \ @@ -116,32 +118,6 @@ order by count(*) desc;").fetchall(); res_groups = [(model.Session.query(model.Group).get(unicode(group_id)), val) for group_id, val in res] return res_groups - - @classmethod - def top_tags(cls, limit=10, returned_tag_info='object'): # by package - assert returned_tag_info in ('name', 'id', 'object') - tag = table('tag') - package_tag = table('package_tag') - package = table('package') - #TODO filter out tags with state=deleted - if returned_tag_info == 'name': - from_obj = [package_tag.join(tag)] - tag_column = tag.c.name - else: - from_obj = None - tag_column = package_tag.c.tag_id - s = select([tag_column, func.count(package_tag.c.package_id)], - from_obj=from_obj) - s = s.group_by(tag_column).\ - where(package.c.private == 'f').\ - order_by(func.count(package_tag.c.package_id).desc()).\ - limit(limit) - res_col = model.Session.execute(s).fetchall() - if returned_tag_info in ('id', 'name'): - return res_col - elif returned_tag_info == 'object': - res_tags = [(model.Session.query(model.Tag).get(unicode(tag_id)), val) for tag_id, val in res_col] - return res_tags @classmethod def top_package_owners(cls, limit=10): @@ -164,11 +140,10 @@ connection = model.Session.connection() res = connection.execute("SELECT 'Total Organisations', count(*) from \"group\" where type = 'organization' and state = 'active' union \ - select 'Total Datasets', count(*) from package where (state='active' or state='draft' or state='draft-complete') and private = 'f' union \ + select 'Total Datasets', count(*) from package inner join (select distinct package_id from resource_group inner join resource on resource.resource_group_id = resource_group.id) as r on package.id = r.package_id where (package.state='active' or package.state='draft' or package.state='draft-complete') and private = 'f' union \ select 'Total Archived Datasets', count(*) from package where (state='active' or state='draft' or state='draft-complete') and private = 't' union \ select 'Total Data Files/Resources', count(*) from resource where state='active' union \ - select 'Total Machine Readable/Data API Resources', count(*) from resource where state='active' and webstore_url = 'active'\ - ").fetchall(); + select 'Total Machine Readable/Data API Resources', count(*) from resource where state='active' and (webstore_url = 'active' or format='wms')").fetchall(); return res --- a/ckanext/dga_stats/templates/ckanext/stats/index.html +++ b/ckanext/dga_stats/templates/ckanext/stats/index.html @@ -305,6 +305,7 @@ +