def report_progress(): """ Generates URLs from report names and validates them. """ req = request.get_json() current_status = list( trait.select(trait.status) .join(report) .filter( trait.trait_slug == req["trait_slug"], (report.report_slug == req["report_slug"]) | (report.report_hash == req["report_slug"]), ) .dicts() .execute() )[0]["status"] return json.dumps(current_status)
def statistics(): title = "Site Statistics" bcs = OrderedDict([("About", url_for("about")), ("Statistics", None)]) # Number of reports n_reports = report.select().count() n_traits = trait.select().count() n_significant_mappings = mapping.select().count() n_distinct_strains = strain.select(strain.strain).distinct().count() n_distinct_isotypes = strain.select(strain.isotype).filter(strain.isotype != None).distinct().count() # Collection dates collection_dates = list(strain.select().filter( strain.isotype != None, strain.isolation_date != None).order_by(strain.isolation_date).execute()) return render_template('statistics.html', **locals())
def public_mapping(): query = request.args.get("query") if query is not None: bcs = OrderedDict([("Public Mappings", url_for("public_mapping")), ("Search", None)]) title = "Search: " + query subtitle = "results" q = "%" + query + "%" results = ( trait.select(report, trait, mapping) .filter(trait.status == "complete", report.release == 0) .join(mapping) .join(report) .dicts() .filter( (trait.trait_slug % q) | (trait.trait_name % q) | (report.report_name % q) | (report.report_slug % q) ) .order_by(mapping.log10p.desc()) ) search_results = list(results.dicts().execute()) search = True return render_template("public_mapping.html", **locals()) title = "Perform Mapping" results = ( trait.select( report.release, report.report_name, report.report_slug, trait.trait_name, trait.trait_slug, trait.status, trait.submission_complete, trait.submission_date, mapping, ) .filter(trait.status == "complete", report.release == 0) .join(mapping, JOIN.LEFT_OUTER) .switch(trait) .join(report) .distinct() .dicts() .order_by(trait.submission_complete.desc()) .execute() ) date_set = dict( Counter([time.mktime((x["submission_date"] + relativedelta(hours=+6)).timetuple()) for x in results]) ) wdata = Counter([(x["submission_date"] + relativedelta(hours=+6)).date().isoformat() for x in results]) waffle_date_set = [{"date": x, "count": y} for x, y in wdata.items()] # added in here waffle_date_set should be filtered by month instead of time stamp. Then could be used for the waffle plot # submission date is a datetime object # waffle_date_set=[] # sum=0 # current_month=results[0]["submission_date"].month # for x in results: # if x["submission_date"].month==current_month: # sum++ # else: # waffle_date_set.append(("month": current_month, "total": sum)) #appending a tuple # sum=1 # current_month=x["submission_date"].month recent_results = list(results)[0:20] bcs = OrderedDict([("Public", None)]) title = "Public Mappings" pub_mappings = list( mapping.select(mapping, report, trait).join(trait).join(report).filter(report.release == 0).dicts().execute() ) return render_template("public_mapping.html", **locals())