def show_stats(deposition_type): """Render the stats for all the depositions.""" if len(DepositionType.keys()) <= 1 and \ DepositionType.get_default() is not None: abort(404) form = FilterDateForm() deptype = DepositionType.get(deposition_type) submitted_depositions = [d for d in Deposition.get_depositions(type=deptype) if d.has_sip(sealed=True)] ctx = process_metadata_for_charts(submitted_depositions, group_by=request.args.get('group_by', 'type_of_doc')) ctx.update(dict( deposition_type=deptype, depositions=submitted_depositions, form=form, chart_types=CHART_TYPES )) return render_template('deposit/stats/all_depositions.html', **ctx)
def stats_api(deposition_type): """Get stats JSON.""" deptype = DepositionType.get(deposition_type) submitted_depositions = [d for d in Deposition.get_depositions(type=deptype) if d.has_sip(sealed=True)] if request.args.get('since_date') is not None: since_date = datetime.strptime(request.args['since_date'], "%Y-%m-%d").replace(hour=0, minute=0) submitted_depositions = [d for d in submitted_depositions if d.created >= since_date] if request.args.get('until_date') is not None: until_date = datetime.strptime(request.args['until_date'], "%Y-%m-%d").replace(hour=23, minute=59) submitted_depositions = [d for d in submitted_depositions if d.created <= until_date] result = process_metadata_for_charts(submitted_depositions, request.args.get('group_by', 'type_of_doc'), bool(request.args.get('include_hidden', None))) resp = jsonify(result) return resp