Пример #1
0
    def index(self):
        c = p.toolkit.c
        stats = stats_lib.Stats()
        rev_stats = stats_lib.RevisionStats()
        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_creators = stats.top_package_creators()
        c.new_packages_by_week = rev_stats.get_by_week('new_packages')
        c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
        c.num_packages_by_week = rev_stats.get_num_packages_by_week()
        c.package_revisions_by_week = rev_stats.get_by_week('package_revisions')

        c.raw_packages_by_week = []
        for week_date, num_packages, cumulative_num_packages in c.num_packages_by_week:
            c.raw_packages_by_week.append({'date': h.date_str_to_datetime(week_date), 'total_packages': cumulative_num_packages})

        c.all_package_revisions = []
        c.raw_all_package_revisions = []
        for week_date, revs, num_revisions, cumulative_num_revisions in c.package_revisions_by_week:
            c.all_package_revisions.append('[new Date(%s), %s]' % (week_date.replace('-', ','), num_revisions))
            c.raw_all_package_revisions.append({'date': h.date_str_to_datetime(week_date), 'total_revisions': num_revisions})

        c.new_datasets = []
        c.raw_new_datasets = []
        for week_date, pkgs, num_packages, cumulative_num_packages in c.new_packages_by_week:
            c.new_datasets.append('[new Date(%s), %s]' % (week_date.replace('-', ','), num_packages))
            c.raw_new_datasets.append({'date': h.date_str_to_datetime(week_date), 'new_packages': num_packages})

        return p.toolkit.render('ckanext/stats/index.html')
Пример #2
0
 def index(self):
     from pylons import tmpl_context as c
     stats = stats_lib.Stats()
     rev_stats = stats_lib.RevisionStats()
     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.new_packages_by_week = rev_stats.get_by_week('new_packages')
     c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
     c.num_packages_by_week = rev_stats.get_num_packages_by_week()
     c.package_revisions_by_week = rev_stats.get_by_week(
         'package_revisions')
     return render('ckanext/stats/index.html')
Пример #3
0
 def index(self):
     c = p.toolkit.c
     stats = stats_lib.Stats()
     rev_stats = stats_lib.RevisionStats()
     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.new_packages_by_week = rev_stats.get_by_week('new_packages')
     c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
     c.num_packages_by_week = rev_stats.get_num_packages_by_week()
     c.package_revisions_by_week = rev_stats.get_by_week(
         'package_revisions')
     return p.toolkit.render('ckanext/stats/index.html')
Пример #4
0
    def index(self):
        c = p.toolkit.c
        stats = stats_lib.Stats()
        rev_stats = stats_lib.RevisionStats()
        c.top_rated_packages = stats.top_rated_packages()
        c.most_edited_packages = stats.most_edited_packages()
        c.largest_groups = stats.largest_groups()
        c.top_package_owners = stats.top_package_owners()
        c.summary_stats = stats.summary_stats()
        c.activity_counts = stats.activity_counts()
        c.by_org = stats.by_org()
        c.by_proj = stats.by_proj()
        c.by_data_type = stats.by_data_type()
        c.res_by_org = stats.res_by_org()
        c.res_by_format = stats.res_by_format()
        c.top_active_orgs = stats.top_active_orgs()
        c.user_access_list = stats.user_access_list()
        c.recent_datasets = stats.recent_datasets()
        c.new_packages_by_week = rev_stats.get_by_week('new_packages')
        c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
        c.num_packages_by_week = rev_stats.get_num_packages_by_week()
        c.package_revisions_by_week = rev_stats.get_by_week('package_revisions')

        # Used in the legacy CKAN templates.
        c.packages_by_week = []

        # Used in new CKAN templates gives more control to the templates for formatting.
        c.raw_packages_by_week = []
        for week_date, num_packages, cumulative_num_packages in c.num_packages_by_week:
            c.packages_by_week.append('[new Date(%s), %s]' % (week_date.replace('-', ','), cumulative_num_packages))
            c.raw_packages_by_week.append({'date': h.date_str_to_datetime(week_date), 'total_packages': cumulative_num_packages})

        c.all_package_revisions = []
        c.raw_all_package_revisions = []
        for week_date, revs, num_revisions, cumulative_num_revisions in c.package_revisions_by_week:
            c.all_package_revisions.append('[new Date(%s), %s]' % (week_date.replace('-', ','), num_revisions))
            c.raw_all_package_revisions.append({'date': h.date_str_to_datetime(week_date), 'total_revisions': num_revisions})

        c.new_datasets = []
        c.raw_new_datasets = []
        for week_date, pkgs, num_packages, cumulative_num_packages in c.new_packages_by_week:
            c.new_datasets.append('[new Date(%s), %s]' % (week_date.replace('-', ','), num_packages))
            c.raw_new_datasets.append({'date': h.date_str_to_datetime(week_date), 'new_packages': num_packages})

        return p.toolkit.render('ckanext/stats/index.html')
Пример #5
0
    def index(self):
        c = p.toolkit.c
        try:
            context = {
                'model': model,
                'user': c.user,
                'auth_user_obj': c.userobj
            }
            logic.check_access('sysadmin', context)
        except logic.NotAuthorized:
            base.abort(403, _('Not authorized to see this page'))

        stats = stats_lib.Stats()
        rev_stats = stats_lib.RevisionStats()
        c.top_rated_packages = stats.top_rated_packages()

        c.most_edited_packages = stats.most_edited_packages()
        export_datasets_most_edited_to_excel(c, stats)

        c.largest_groups = stats.largest_groups()
        export_largest_groups_to_excel(c, stats)

        c.top_tags = stats.top_tags()
        export_tags_to_excel(c, stats)

        c.top_package_creators = stats.top_package_creators()
        export_top_users_to_excel(c, stats)

        c.new_packages_by_week = rev_stats.get_by_week('new_packages')
        c.deleted_packages_by_week = rev_stats.get_by_week('deleted_packages')
        c.num_packages_by_week = rev_stats.get_num_packages_by_week()
        c.package_revisions_by_week = rev_stats.get_by_week(
            'package_revisions')

        c.modified_resources = stats.modified_resources()
        export_modified_resources_to_excel(c, stats)

        c.org_resources = stats.org_resources()
        export_org_resources_to_excel(c, stats)

        c.datapusher_tasks = stats.datapusher_tasks()
        export_datapush_tasks_to_excel(c, stats)

        c.raw_packages_by_week = []
        for week_date, num_packages, cumulative_num_packages in c.num_packages_by_week:
            c.raw_packages_by_week.append({
                'date':
                h.date_str_to_datetime(week_date),
                'total_packages':
                cumulative_num_packages
            })

        c.all_package_revisions = []
        c.raw_all_package_revisions = []
        for week_date, revs, num_revisions, cumulative_num_revisions in c.package_revisions_by_week:
            c.all_package_revisions.append(
                '[new Date(%s), %s]' %
                (week_date.replace('-', ','), num_revisions))
            c.raw_all_package_revisions.append({
                'date':
                h.date_str_to_datetime(week_date),
                'total_revisions':
                num_revisions
            })

        c.new_datasets = []
        c.raw_new_datasets = []
        for week_date, pkgs, num_packages, cumulative_num_packages in c.new_packages_by_week:
            c.new_datasets.append('[new Date(%s), %s]' %
                                  (week_date.replace('-', ','), num_packages))
            c.raw_new_datasets.append({
                'date': h.date_str_to_datetime(week_date),
                'new_packages': num_packages
            })

        return p.toolkit.render('ckanext/stats/index.html')