def index_plot_data_cache(summary_form): key = summary_form.caching_key() cached = flask_cache.get(key) if cached is not None: return cached reports = [] hist_table, hist_field = get_history_target( summary_form.resolution.data) component_ids = component_names_to_ids(summary_form.component_names.data) (since_date, to_date) = summary_form.daterange.data if summary_form.opsysreleases.data: opsysreleases = summary_form.opsysreleases.data else: opsysreleases = ( db.session.query(OpSysRelease) .filter(OpSysRelease.status != "EOL") .order_by(OpSysRelease.releasedate) .all()) for osr in opsysreleases: counts = ( db.session.query(hist_field.label("time"), func.sum(hist_table.count).label("count")) .group_by(hist_field) .order_by(hist_field)) counts = counts.filter(hist_table.opsysrelease_id == osr.id) if component_ids: counts = (counts.join(Report) .filter(Report.component_id.in_(component_ids))) counts = (counts.filter(hist_field >= since_date) .filter(hist_field <= to_date)) counts = counts.all() dates = set(date_iterator(since_date, summary_form.resolution.data, to_date)) for time, count in counts: dates.remove(time) for date in dates: counts.append((date, 0)) counts = sorted(counts, key=itemgetter(0)) reports.append((str(osr), counts)) cached = render_template("summary/index_plot_data.html", reports=reports, resolution=summary_form.resolution.data[0]) flask_cache.set(key, cached, timeout=60*60) return cached
def get_reports(filter_form, pagination): opsysrelease_ids = [ osr.id for osr in (filter_form.opsysreleases.data or []) ] component_ids = component_names_to_ids(filter_form.component_names.data) if filter_form.associate.data: associate_id = filter_form.associate.data.id else: associate_id = None arch_ids = [arch.id for arch in (filter_form.arch.data or [])] types = filter_form.type.data or [] r = query_reports( db, opsysrelease_ids=opsysrelease_ids, component_ids=component_ids, associate_id=associate_id, arch_ids=arch_ids, types=types, first_occurrence_since=filter_form.first_occurrence_daterange.data and filter_form.first_occurrence_daterange.data[0], first_occurrence_to=filter_form.first_occurrence_daterange.data and filter_form.first_occurrence_daterange.data[1], last_occurrence_since=filter_form.last_occurrence_daterange.data and filter_form.last_occurrence_daterange.data[0], last_occurrence_to=filter_form.last_occurrence_daterange.data and filter_form.last_occurrence_daterange.data[1], limit=pagination.limit, offset=pagination.offset, order_by=filter_form.order_by.data) return r
def get_reports(filter_form, pagination): opsysrelease_ids = [ osr.id for osr in (filter_form.opsysreleases.data or [])] component_ids = component_names_to_ids(filter_form.component_names.data) if filter_form.associate.data: associate_id = filter_form.associate.data.id else: associate_id = None arch_ids = [arch.id for arch in (filter_form.arch.data or [])] types = filter_form.type.data or [] r = query_reports( db, opsysrelease_ids=opsysrelease_ids, component_ids=component_ids, associate_id=associate_id, arch_ids=arch_ids, types=types, first_occurrence_since=filter_form.first_occurrence_daterange.data and filter_form.first_occurrence_daterange.data[0], first_occurrence_to=filter_form.first_occurrence_daterange.data and filter_form.first_occurrence_daterange.data[1], last_occurrence_since=filter_form.last_occurrence_daterange.data and filter_form.last_occurrence_daterange.data[0], last_occurrence_to=filter_form.last_occurrence_daterange.data and filter_form.last_occurrence_daterange.data[1], limit=pagination.limit, offset=pagination.offset, order_by=filter_form.order_by.data) return r
def index_plot_data_cache(summary_form): key = summary_form.caching_key() cached = flask_cache.get(key) if cached is not None: return cached reports = [] hist_table, hist_field = get_history_target(summary_form.resolution.data) component_ids = component_names_to_ids(summary_form.component_names.data) (since_date, to_date) = summary_form.daterange.data if summary_form.opsysreleases.data: opsysreleases = summary_form.opsysreleases.data else: opsysreleases = (db.session.query(OpSysRelease).filter( OpSysRelease.status != "EOL").order_by( OpSysRelease.releasedate).all()) for osr in opsysreleases: counts = (db.session.query( hist_field.label("time"), func.sum(hist_table.count).label("count")).group_by( hist_field).order_by(hist_field)) counts = counts.filter(hist_table.opsysrelease_id == osr.id) if component_ids: counts = (counts.join(Report).filter( Report.component_id.in_(component_ids))) counts = (counts.filter(hist_field >= since_date).filter( hist_field <= to_date)) counts = counts.all() dates = set( date_iterator(since_date, summary_form.resolution.data, to_date)) for time, count in counts: dates.remove(time) for date in dates: counts.append((date, 0)) counts = sorted(counts, key=itemgetter(0)) reports.append((str(osr), counts)) cached = render_template("summary/index_plot_data.html", reports=reports, resolution=summary_form.resolution.data[0]) flask_cache.set(key, cached, timeout=60 * 60) return cached
def get_problems(filter_form, pagination): opsysrelease_ids = [ osr.id for osr in (filter_form.opsysreleases.data or []) ] component_ids = component_names_to_ids(filter_form.component_names.data) if filter_form.associate.data: associate_id = filter_form.associate.data.id else: associate_id = None arch_ids = [arch.id for arch in (filter_form.arch.data or [])] types = filter_form.type.data or [] exclude_taintflag_ids = [ tf.id for tf in (filter_form.exclude_taintflags.data or []) ] (since_date, to_date) = filter_form.daterange.data date_delta = to_date - since_date if date_delta < datetime.timedelta(days=16): resolution = "daily" elif date_delta < datetime.timedelta(weeks=10): resolution = "weekly" else: resolution = "monthly" hist_table, hist_field = get_history_target(resolution) probable_fix_osr_ids = [ osr.id for osr in (filter_form.probable_fix_osrs.data or []) ] p = query_problems( db, hist_table, hist_field, opsysrelease_ids=opsysrelease_ids, component_ids=component_ids, associate_id=associate_id, arch_ids=arch_ids, exclude_taintflag_ids=exclude_taintflag_ids, types=types, rank_filter_fn=lambda query: (query.filter(hist_field >= since_date).filter(hist_field <= to_date)), function_names=filter_form.function_names.data, binary_names=filter_form.binary_names.data, source_file_names=filter_form.source_file_names.data, since_version=filter_form.since_version.data, since_release=filter_form.since_release.data, to_version=filter_form.to_version.data, to_release=filter_form.to_release.data, probable_fix_osr_ids=probable_fix_osr_ids, bug_filter=filter_form.bug_filter.data, limit=pagination.limit, offset=pagination.offset, solution=filter_form.solution) return p
def get_problems(filter_form, pagination): opsysrelease_ids = [ osr.id for osr in (filter_form.opsysreleases.data or []) ] component_ids = component_names_to_ids(filter_form.component_names.data) if filter_form.associate.data: associate_id = filter_form.associate.data.id else: associate_id = None arch_ids = [arch.id for arch in (filter_form.arch.data or [])] types = filter_form.type.data or [] exclude_taintflag_ids = [ tf.id for tf in (filter_form.exclude_taintflags.data or []) ] (since_date, to_date) = filter_form.daterange.data date_delta = to_date - since_date if date_delta < datetime.timedelta(days=16): resolution = "daily" elif date_delta < datetime.timedelta(weeks=10): resolution = "weekly" else: resolution = "monthly" hist_table, hist_field = get_history_target(resolution) probable_fix_osr_ids = [ osr.id for osr in (filter_form.probable_fix_osrs.data or []) ] p = query_problems( db, hist_table, hist_field, opsysrelease_ids=opsysrelease_ids, component_ids=component_ids, associate_id=associate_id, arch_ids=arch_ids, exclude_taintflag_ids=exclude_taintflag_ids, types=types, rank_filter_fn= lambda query: (query.filter(hist_field >= since_date).filter(hist_field <= to_date)), function_names=filter_form.function_names.data, binary_names=filter_form.binary_names.data, source_file_names=filter_form.source_file_names.data, since_version=filter_form.since_version.data, since_release=filter_form.since_release.data, to_version=filter_form.to_version.data, to_release=filter_form.to_release.data, probable_fix_osr_ids=probable_fix_osr_ids, bug_filter=filter_form.bug_filter.data, limit=pagination.limit, offset=pagination.offset) return p