def v4_new_regressions(): form = TriagePageSelectedForm(request.form) session = request.session ts = request.get_testsuite() if request.method == 'POST' and \ request.form['btn'] == "Create New Regression": regression, _ = new_regression(session, ts, form.field_changes.data) flash("Created " + regression.title, FLASH_SUCCESS) return redirect( v4_url_for(".v4_regression_list", highlight=regression.id)) if request.method == 'POST' and request.form['btn'] == "Ignore Changes": msg = "Ignoring changes: " ignored = [] for fc_id in form.field_changes.data: ignored.append(str(fc_id)) fc = get_fieldchange(session, ts, fc_id) ignored_change = ts.ChangeIgnore(fc) session.add(ignored_change) session.commit() flash(msg + ", ".join(ignored), FLASH_SUCCESS) # d = datetime.datetime.now() # two_weeks_ago = d - datetime.timedelta(days=14) recent_fieldchange = session.query(ts.FieldChange) \ .join(ts.Test) \ .outerjoin(ts.ChangeIgnore) \ .filter(ts.ChangeIgnore.id.is_(None)) \ .outerjoin(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.id.is_(None)) \ .order_by(desc(ts.FieldChange.id)) \ .limit(500) \ .all() crs = [] form.field_changes.choices = list() for fc in recent_fieldchange: if fc.old_value is None: cr, key_run, _ = get_cr_for_field_change(session, ts, fc) else: cr = PrecomputedCR(fc.old_value, fc.new_value, fc.field.bigger_is_better) key_run = get_first_runs_of_fieldchange(session, ts, fc) current_cr, _, _ = get_cr_for_field_change(session, ts, fc, current=True) crs.append(ChangeData(fc, cr, key_run, current_cr)) form.field_changes.choices.append(( fc.id, 1, )) return render_template("v4_new_regressions.html", testsuite_name=g.testsuite_name, changes=crs, analysis=lnt.server.reporting.analysis, form=form, **ts_data(ts))
def v4_regression_detail(id): ts = request.get_testsuite() form = EditRegressionForm(request.form) try: regression_info = ts.query(ts.Regression) \ .filter(ts.Regression.id == id) \ .one() except NoResultFound as e: abort(404) if request.method == 'POST' and request.form['save_btn'] == "Save Changes": regression_info.title = form.title.data regression_info.bug = form.bug.data regression_info.state = form.state.data ts.commit() flash("Updated " + regression_info.title, FLASH_SUCCESS) return redirect( v4_url_for("v4_regression_list", highlight=regression_info.id, state=int(form.edit_state.data))) if request.method == 'POST' and request.form[ 'save_btn'] == "Split Regression": # For each of the regression indicators, grab their field ids. res_inds = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.field_change_id.in_(form.field_changes.data)) \ .all() fc_ids = [x.field_change_id for x in res_inds] second_regression = new_regression(ts, fc_ids) second_regression.state = regression_info.state # Now remove our links to this regression. for res_ind in res_inds: ts.delete(res_ind) lnt.server.db.fieldchange.rebuild_title(ts, regression_info) ts.commit() flash("Split " + second_regression.title, FLASH_SUCCESS) return redirect( v4_url_for("v4_regression_list", highlight=second_regression.id, state=int(form.edit_state.data))) if request.method == 'POST' and request.form['save_btn'] == "Delete": # For each of the regression indicators, grab their field ids. title = regression_info.title res_inds = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.regression_id == regression_info.id) \ .all() # Now remove our links to this regression. for res_ind in res_inds: ts.delete(res_ind) ts.delete(regression_info) ts.commit() flash("Deleted " + title, FLASH_SUCCESS) return redirect( v4_url_for("v4_regression_list", state=int(form.edit_state.data))) form.field_changes.choices = list() form.state.default = regression_info.state form.process() form.edit_state.data = regression_info.state form.title.data = regression_info.title form.bug.data = regression_info.bug regression_indicators = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.regression_id == id) \ .all() crs = [] test_suite_versions = set() form.field_changes.choices = list() # If we have more than 10 regressions, don't graph any by default. checkbox_state = 1 if len(regression_indicators) >= 10: checkbox_state = 0 for regression in regression_indicators: fc = regression.field_change if fc is None: continue if fc.old_value is None: cr, key_run, all_runs = get_cr_for_field_change(ts, fc) else: cr = PrecomputedCR(fc.old_value, fc.new_value, fc.field.bigger_is_better) key_run = get_first_runs_of_fieldchange(ts, fc) current_cr, _, all_runs = get_cr_for_field_change(ts, fc, current=True) crs.append(ChangeData(fc, cr, key_run, current_cr)) form.field_changes.choices.append(( fc.id, checkbox_state, )) for run in all_runs: ts_rev = key_run.parameters.get('test_suite_revision') if ts_rev and ts_rev != u'None': test_suite_versions.add(ts_rev) if len(test_suite_versions) > 1: revs = ', '.join(list(test_suite_versions)) flash("More than one test-suite version: " + revs, FLASH_DANGER) if request.args.get('json'): return json.dumps({ u'Regression': regression_info, u'Changes': crs }, cls=LNTEncoder) return render_template("v4_regression_detail.html", testsuite_name=g.testsuite_name, regression=regression_info, changes=crs, form=form, analysis=lnt.server.reporting.analysis, check_all=checkbox_state)
def v4_regression_detail(id): ts = request.get_testsuite() form = EditRegressionForm(request.form) regression_info = ts.query(ts.Regression) \ .filter(ts.Regression.id == id) \ .one() if request.method == 'POST' and request.form['save_btn'] == "Save Changes": regression_info.title = form.title.data regression_info.bug = form.bug.data regression_info.state = form.state.data ts.commit() flash("Updated " + regression_info.title, FLASH_SUCCESS) return redirect( v4_url_for("v4_regression_list", highlight=regression_info.id, state=regression_info.state)) if request.method == 'POST' and request.form[ 'save_btn'] == "Split Regression": # For each of the regression indicators, grab their field ids. res_inds = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.field_change_id.in_(form.field_changes.data)) \ .all() fc_ids = [x.field_change_id for x in res_inds] second_regression = new_regression(ts, fc_ids) second_regression.state = regression_info.state # Now remove our links to this regression. for res_ind in res_inds: ts.delete(res_ind) lnt.server.db.fieldchange.rebuild_title(ts, regression_info) ts.commit() flash("Split " + second_regression.title, FLASH_SUCCESS) return redirect( v4_url_for("v4_regression_list", highlight=second_regression.id)) if request.method == 'POST' and request.form['save_btn'] == "Delete": # For each of the regression indicators, grab their field ids. title = regression_info.title res_inds = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.regression_id == regression_info.id) \ .all() # Now remove our links to this regression. for res_ind in res_inds: ts.delete(res_ind) ts.delete(regression_info) ts.commit() flash("Deleted " + title, FLASH_SUCCESS) return redirect(v4_url_for("v4_regression_list")) form.field_changes.choices = list() form.state.default = regression_info.state form.process() form.title.data = regression_info.title form.bug.data = regression_info.bug regression_indicators = ts.query(ts.RegressionIndicator) \ .filter(ts.RegressionIndicator.regression_id == id) \ .all() crs = [] form.field_changes.choices = list() for regression in regression_indicators: fc = regression.field_change if fc is None: continue if fc.old_value is None: cr, key_run = get_cr_for_field_change(ts, fc) else: cr = PrecomputedCR(fc.old_value, fc.new_value, fc.field.bigger_is_better) key_run = get_first_runs_of_fieldchange(ts, fc) current_cr, _ = get_cr_for_field_change(ts, fc, current=True) crs.append(ChangeData(fc, cr, key_run, current_cr)) form.field_changes.choices.append(( fc.id, 1, )) return render_template("v4_regression_detail.html", testsuite_name=g.testsuite_name, regression=regression_info, changes=crs, form=form, analysis=lnt.server.reporting.analysis)