Exemplo n.º 1
0
 def _process(self):
     stats = get_category_stats(self.category.id)
     if request.accept_mimetypes.best_match(
         ('application/json', 'text/html')) == 'application/json':
         return self._get_stats_json(stats)
     else:
         return self._get_stats_html(stats)
Exemplo n.º 2
0
 def _process(self):
     stats = get_category_stats(self.category.id)
     if 'min_year' not in stats:
         # in case the instance was freshly updated and still has data
         # cached we need to invalidate it to avoid breaking the page
         # TODO: remove this in 3.0; by then people had enough time to update to 2.3...
         get_category_stats.clear_cached(self.category.id)
         stats = get_category_stats(self.category.id)
     data = {
         'events': stats['events_by_year'],
         'contributions': stats['contribs_by_year'],
         'files': stats['attachments'],
         'updated': stats['updated'].isoformat(),
         'total_events': sum(stats['events_by_year'].values()),
         'total_contributions': sum(stats['contribs_by_year'].values()),
         'min_year': stats['min_year'],
         'max_year': date.today().year,
     }
     if self.category.is_root:
         data['users'] = User.query.filter_by(is_deleted=False, is_pending=False).count()
     return jsonify(data)
Exemplo n.º 3
0
 def _process(self):
     stats = get_category_stats(int(self._target.getId()))
     if request.accept_mimetypes.best_match(('application/json', 'text/html')) == 'application/json':
         data = {'events': stats['events_by_year'], 'contributions': stats['contribs_by_year'],
                 'files': stats['attachments'], 'updated': stats['updated'].isoformat()}
         if self._target.isRoot():
             data['users'] = _count_users()
         return jsonify(data)
     else:
         plots, values, updated = _process_stats(stats, root=self._target.isRoot())
         return WPCategoryStatistics.render_template('category_statistics.html', self._target,
                                                     cat=self._target,
                                                     plots=plots,
                                                     values=values,
                                                     updated=updated,
                                                     has_stats=True)
Exemplo n.º 4
0
 def _process(self):
     stats = get_category_stats(int(self._target.getId()))
     if request.accept_mimetypes.best_match(
         ('application/json', 'text/html')) == 'application/json':
         data = {
             'events': stats['events_by_year'],
             'contributions': stats['contribs_by_year'],
             'files': stats['attachments'],
             'updated': stats['updated'].isoformat()
         }
         if self._target.isRoot():
             data['users'] = _count_users()
         return jsonify(data)
     else:
         plots, values, updated = _process_stats(stats,
                                                 root=self._target.isRoot())
         return WPCategoryStatistics.render_template(
             'category_statistics.html',
             self._target,
             cat=self._target,
             plots=plots,
             values=values,
             updated=updated,
             has_stats=True)
Exemplo n.º 5
0
 def _process(self):
     stats = get_category_stats(self.category.id)
     if request.accept_mimetypes.best_match(('application/json', 'text/html')) == 'application/json':
         return self._get_stats_json(stats)
     else:
         return self._get_stats_html(stats)