mirror of
https://github.com/YunoHost/tartiflette.git
synced 2024-09-03 20:06:08 +02:00
Updates were registering lot of duplicate tests, causing perf issues
This commit is contained in:
parent
2f179a32d1
commit
5f1cc27954
1 changed files with 22 additions and 12 deletions
|
@ -39,14 +39,15 @@ class AppCIBranch(db.Model):
|
||||||
def most_recent_tests_per_app(self):
|
def most_recent_tests_per_app(self):
|
||||||
|
|
||||||
apps = App.query.filter_by(ci_enabled=True).all()
|
apps = App.query.filter_by(ci_enabled=True).all()
|
||||||
for app in apps:
|
most_recent_tests = AppCIResult.query \
|
||||||
most_recent_test = AppCIResult.query \
|
|
||||||
.filter_by(branch = self) \
|
.filter_by(branch = self) \
|
||||||
.filter_by(app = app) \
|
|
||||||
.order_by('date desc') \
|
.order_by('date desc') \
|
||||||
.first()
|
.all()
|
||||||
|
|
||||||
|
for app in apps:
|
||||||
|
most_recent_test = [ t for t in most_recent_tests if t.app == app ]
|
||||||
if most_recent_test:
|
if most_recent_test:
|
||||||
yield most_recent_test
|
yield most_recent_test[0]
|
||||||
else:
|
else:
|
||||||
yield AppCIResult(app = app,
|
yield AppCIResult(app = app,
|
||||||
branch = self,
|
branch = self,
|
||||||
|
@ -122,10 +123,19 @@ class AppCI():
|
||||||
for test, result in zip(AppCI.tests, test_summary["detailled_success"]):
|
for test, result in zip(AppCI.tests, test_summary["detailled_success"]):
|
||||||
test_results[test] = bool(int(result)) if result in [ "1", "0" ] else None
|
test_results[test] = bool(int(result)) if result in [ "1", "0" ] else None
|
||||||
|
|
||||||
results = AppCIResult(app = App.query.filter_by(name=test_summary["app"]).first(),
|
app = App.query.filter_by(name=test_summary["app"]).first()
|
||||||
|
date = datetime.datetime.fromtimestamp(test_summary["timestamp"])
|
||||||
|
|
||||||
|
existing_test = AppCIResult.query \
|
||||||
|
.filter_by(branch = cibranch) \
|
||||||
|
.filter_by(date = date) \
|
||||||
|
.first()
|
||||||
|
|
||||||
|
if not existing_test:
|
||||||
|
results = AppCIResult(app = app,
|
||||||
branch = cibranch,
|
branch = cibranch,
|
||||||
level = test_summary["level"],
|
level = test_summary["level"],
|
||||||
date = datetime.datetime.fromtimestamp(test_summary["timestamp"]),
|
date = date,
|
||||||
results = test_results)
|
results = test_results)
|
||||||
db.session.add(results)
|
db.session.add(results)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue