 
   weakestSections: (sections, sampleSizeThreshold, displayCount = 4) ->
     validSections = @filterForecastedSections(sections, sampleSizeThreshold)
-    displayCount = Math.min(Math.floor(validSections.length / 2), displayCount)
+
+    # Select at least one, but no more than displayCount(4)
+    displayCount = Math.min(
+      Math.max(1, Math.floor(validSections.length / 2))
+      , displayCount)
+
 
     # Sort by value and pick 'displayCount' of the weakest
     _.chain(validSections)


  canPractice: ({sections, sampleSizeThreshold, displayCount, minimumSectionCount}) ->
    displayCount ||= 4
    minimumSectionCount ||= 2
    @weakestSections(sections, sampleSizeThreshold, displayCount).length >= minimumSectionCount

  pagesForSections: (sections) ->
    _.chain(sections).pluck('page_ids').flatten().uniq().value()

}, new CrudConfig

Helpers = {
  # Since the learning guide doesn't currently include worked dates
  # the best we can do is return from the end of the list
  recentSections: (sections, limit = 4) ->
    _.last(sections, limit)

  canDisplayForecast: (clue, sampleSizeThreshold) ->
    clue.sample_size >= sampleSizeThreshold or clue.sample_size_interpretation isnt 'below'
