|
@@ -105,19 +105,33 @@ class Result(db.Model):
|
|
participant_id = db.Column(db.Integer, db.ForeignKey('participant.id'))
|
|
participant_id = db.Column(db.Integer, db.ForeignKey('participant.id'))
|
|
participant = db.relationship('Participant',
|
|
participant = db.relationship('Participant',
|
|
backref=db.backref('results', lazy='dynamic'))
|
|
backref=db.backref('results', lazy='dynamic'))
|
|
- # In milliseconds
|
|
|
|
- rtt = db.Column(db.Float)
|
|
|
|
# Date at which the result was reported back to us
|
|
# Date at which the result was reported back to us
|
|
date = db.Column(db.DateTime)
|
|
date = db.Column(db.DateTime)
|
|
-
|
|
|
|
- def __init__(self, target_id, participant_uuid, rtt):
|
|
|
|
|
|
+ # In milliseconds
|
|
|
|
+ avgrtt = db.Column(db.Float)
|
|
|
|
+ # All these are optional
|
|
|
|
+ minrtt = db.Column(db.Float)
|
|
|
|
+ maxrtt = db.Column(db.Float)
|
|
|
|
+ jitter = db.Column(db.Float)
|
|
|
|
+ # Number of ping requests
|
|
|
|
+ probes_sent = db.Column(db.Integer)
|
|
|
|
+ # Number of successful probes
|
|
|
|
+ probes_received = db.Column(db.Integer)
|
|
|
|
+
|
|
|
|
+ def __init__(self, target_id, participant_uuid, avgrtt, minrtt, maxrtt,
|
|
|
|
+ jitter, probes_sent, probes_received):
|
|
target = Target.query.get_or_404(int(target_id))
|
|
target = Target.query.get_or_404(int(target_id))
|
|
participant = Participant.query.filter_by(uuid=participant_uuid,
|
|
participant = Participant.query.filter_by(uuid=participant_uuid,
|
|
active=True).first_or_404()
|
|
active=True).first_or_404()
|
|
self.target = target
|
|
self.target = target
|
|
self.participant = participant
|
|
self.participant = participant
|
|
- self.rtt = float(rtt)
|
|
|
|
self.date = datetime.now()
|
|
self.date = datetime.now()
|
|
|
|
+ self.avgrtt = float(avgrtt)
|
|
|
|
+ self.minrtt = float(minrtt) if minrtt is not None else None
|
|
|
|
+ self.maxrtt = float(maxrtt) if maxrtt is not None else None
|
|
|
|
+ self.jitter = float(jitter) if jitter is not None else None
|
|
|
|
+ self.probes_sent = int(probes_sent) if probes_sent is not None else None
|
|
|
|
+ self.probes_received = int(probes_received) if probes_received is not None else None
|
|
|
|
|
|
|
|
|
|
def init_db():
|
|
def init_db():
|
|
@@ -199,10 +213,13 @@ def get_next_target_family(uuid, family):
|
|
|
|
|
|
@app.route('/result/report/<uuid>', methods=['POST'])
|
|
@app.route('/result/report/<uuid>', methods=['POST'])
|
|
def report_result(uuid):
|
|
def report_result(uuid):
|
|
- if {'rtt', 'target'}.issubset(request.form):
|
|
|
|
|
|
+ if {'avgrtt', 'target'}.issubset(request.form):
|
|
target_id = request.form['target']
|
|
target_id = request.form['target']
|
|
- rtt = request.form['rtt']
|
|
|
|
- result = Result(target_id, uuid, rtt)
|
|
|
|
|
|
+ avgrtt = request.form['avgrtt']
|
|
|
|
+ optional_args = [request.form.get(f) for f in
|
|
|
|
+ ('minrtt', 'maxrtt', 'jitter', 'probes_sent',
|
|
|
|
+ 'probes_received')]
|
|
|
|
+ result = Result(target_id, uuid, avgrtt, *optional_args)
|
|
db.session.add(result)
|
|
db.session.add(result)
|
|
# Record that the participant has returned a result
|
|
# Record that the participant has returned a result
|
|
participant = result.participant
|
|
participant = result.participant
|
|
@@ -215,7 +232,7 @@ def report_result(uuid):
|
|
@app.route('/result/show/<target_uniqueid>')
|
|
@app.route('/result/show/<target_uniqueid>')
|
|
def show_results(target_uniqueid):
|
|
def show_results(target_uniqueid):
|
|
target = Target.query.filter_by(unique_id=target_uniqueid).first_or_404()
|
|
target = Target.query.filter_by(unique_id=target_uniqueid).first_or_404()
|
|
- results = target.results.order_by('rtt').all()
|
|
|
|
|
|
+ results = target.results.order_by('avgrtt').all()
|
|
return render_template('results.html', target=target, results=results)
|
|
return render_template('results.html', target=target, results=results)
|
|
|
|
|
|
|
|
|