Repository: LMFDB/lmfdb

Issue:
Elliptic curve completeness information bug
From the feedback page:

I tried to go to the page 

https://www.lmfdb.org/EllipticCurve/Q/Completeness

 and it gave the error "This information can only be displayed with a more recent version of the LMFDB."

(This error comes up if the summary function is not available, so it looks like a coding bug.)



Discussion:
I'm looking at this now, but have no idea what the cause is.  Displaying this knowl  shows the same text (http://localhost:37777/knowledge/show/dq.ec.extent).  I hope the real knowl content is still there somewhere.
Looks like this is happening because the function elliptic_curve_summary was deleted in #4178 
the knowl content is just 
```
{% if elliptic_curve_summary is defined %}
  {{elliptic_curve_summary()| safe}}
{% else %}
  This information can only be displayed with a more recent version of the LMFDB.
{% endif %}
```
upon edit after all
Well spotted, Alex!  Can you fix this then?

This absolutely should not have happened.  How can we delete a function which is needed and not notice? There should be a test for this specific page as part of the fix, and we should also collect a list of the functions called in knowls in this way and have tests for every one of them.  

The relevant deleted lines from the (completely deleted) file ec_stats.py are

def elliptic_curve_summary():
    counts = get_stats().counts()
    return r'The database currently contains the complete Cremona database.  This contains all %s <a title="Elliptic curves [ec]" knowl="ec" kwargs="">elliptic curves</a> defined over $\Q$ with <a title="Conductor of an elliptic curve over $\Q$ [ec.q.conductor]" knowl="ec.q.conductor" kwargs="">conductor</a> at most %s.' % (str(counts['ncurves_c']), str(counts['max_N_c']))


@app.context_processor
def ctx_elliptic_curve_summary():
    return {'elliptic_curve_summary': elliptic_curve_summary}

and the correct text will be returned by ECStats.summary().  It's also necessary to have the function registered using the context_processor stuff.
Yeah I tried, but I can't get it to work and I have no idea why. I'm trying to pass the ECStats().summary through to the page via `info` but nothing I did made the knowl appear correctly.
OK, I think I know how to do this so let me try.

Resolving patch:
diff --git a/lmfdb/elliptic_curves/elliptic_curve.py b/lmfdb/elliptic_curves/elliptic_curve.py
--- a/lmfdb/elliptic_curves/elliptic_curve.py
+++ b/lmfdb/elliptic_curves/elliptic_curve.py
@@ -215,6 +215,12 @@ def isogeny_degrees(self):
         cur = db._execute(SQL("SELECT UNIQ(SORT(ARRAY_AGG(elements ORDER BY elements))) FROM ec_curves, UNNEST(isodeg) as elements"))
         return cur.fetchone()[0]
 
+# NB the contex processor wants something callable and the summary is a *property*
+
+@app.context_processor
+def ctx_elliptic_curve_summary():
+    return {'elliptic_curve_summary': lambda: ECstats().summary}
+
 @ec_page.route("/stats")
 def statistics():
     title = r'Elliptic curves over $\Q$: Statistics'


Test patch:
diff --git a/lmfdb/elliptic_curves/test_ell_curves.py b/lmfdb/elliptic_curves/test_ell_curves.py
--- a/lmfdb/elliptic_curves/test_ell_curves.py
+++ b/lmfdb/elliptic_curves/test_ell_curves.py
@@ -145,3 +145,10 @@ def test_990h(self):
         #print L.get_data(as_text=True)
         self.assertTrue(row in L.get_data(as_text=True),
                         "990h appears to have the wrong optimal curve.")
+
+    def test_completeness(self):
+        """
+        Test that the dynamic completeness knowl displays OK.
+        """
+        L = self.tc.get('/EllipticCurve/Q/Completeness')
+        assert 'The database currently contains' in L.get_data(as_text=True)