Skip to content

Commit 35fbdcd

Browse files
committed
Turn grid limit into setting
- add helper method to read setting with default value if not present Signed-off-by: Stefan Marr <git@stefan-marr.de>
1 parent e3b1e9c commit 35fbdcd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

codespeed/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
DEF_TIMELINE_LIMIT = 50 # Default number of revisions to be plotted
4141
# Possible values 10,50,200,1000
4242

43+
TIMELINE_GRID_LIMIT = 30 # Number of benchmarks beyond which the timeline view
44+
# is disabled as default setting. Too many benchmarks make
45+
# the view slow, and put load on the database, which may be
46+
# undeseriable.
47+
4348
#TIMELINE_BRANCHES = True # NOTE: Only the default branch is currently shown
4449
# Get timeline results for specific branches
4550
# Set to False if you want timeline plots and results only for trunk.

codespeed/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ def comparison(request):
224224
'selecteddirection': selecteddirection
225225
})
226226

227+
def get_setting(name, default = None):
228+
if hasattr(settings, name):
229+
return getattr(settings, name)
230+
else:
231+
return default
232+
227233

228234
@require_GET
229235
def gettimelinedata(request):
@@ -442,7 +448,7 @@ def timeline(request):
442448
defaultlast = data['revs']
443449

444450
benchmarks = Benchmark.objects.all()
445-
grid_limit = 30
451+
446452
defaultbenchmark = "grid"
447453
if not len(benchmarks):
448454
return no_data_found(request)
@@ -457,7 +463,7 @@ def timeline(request):
457463
name=settings.DEF_BENCHMARK)
458464
except Benchmark.DoesNotExist:
459465
pass
460-
elif len(benchmarks) >= grid_limit:
466+
elif len(benchmarks) >= get_setting('TIMELINE_GRID_LIMIT', 30):
461467
defaultbenchmark = 'show_none'
462468

463469
if 'ben' in data and data['ben'] != defaultbenchmark:

0 commit comments

Comments
 (0)