chiark / gitweb /
Added listing by age at birth of child to web
authornaath <naath@chiark.greenend.org.uk>
Sun, 6 Apr 2014 17:14:36 +0000 (18:14 +0100)
committernaath <naath@chiark.greenend.org.uk>
Sun, 6 Apr 2014 17:14:36 +0000 (18:14 +0100)
cgiFiles/ancestors.py [changed mode: 0755->0644]
cgiFiles/countNames.py [changed mode: 0755->0644]
cgiFiles/everyPage.py [changed mode: 0755->0644]
cgiFiles/listPeople.py [changed mode: 0755->0644]
cgiFiles/listTerr.py [changed mode: 0755->0644]
cgiFiles/person.py [changed mode: 0755->0644]
cgiFiles/territory.py [changed mode: 0755->0644]
familyTree/askQuestion.py

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 08e2d2e..d202b61
@@ -17,6 +17,9 @@ def links():
        print '<a href='+base_url() + 'listTerr.py> list of territories</a>'
        print '<br>'
        print '<a href='+base_url() + 'countNames.py> count how many times first names are use</a>'
+       print '<br>'
+       print '<a href='+base_url()+ 'listAge.py> At what age did people have children</a>'
+
 
        print '<hr>'
 def footer():
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6e9642635213f84bc4ac330d7f71103bdaadd63f..179888c62ab38b357a019de984fdad3bc27066db 100755 (executable)
@@ -63,10 +63,22 @@ def name_html(row,html):
                if html==1:
                        script = "person.py?ID=" + str(row[1])
                        name = row[0]
-                       return link_Template.substitute(script = script, text = name)
+                       return link_Template.substitute(script = script\
+                               , text = name)
                else:
                        return row[0] + "," +str(row[1])
 
+def print_age_count(row,newLine):
+       if newLine == '<br>':
+               script = "age.py?age="+str(row[0])
+               link = link_Template.substitute(script = \
+                       script, text = row[0])
+               return str(row[1]) + ' people had children at age '\
+                        + link + newLine
+       else:
+               return print_row(row,newLine)
+       
+
 def print_tagged_name(relationship,row,newLine):
        if row[0]==None:
                        out = relationship + " not yet entered: " + row[1]
@@ -134,6 +146,7 @@ def list_territories(newLine):
                out =out + terr_html(row[0],newLine) +newLine
        return out
 
+
 def list_people(newLine):
        s = "SELECT name,id,bornyear"\
        +" FROM people"\
@@ -268,7 +281,10 @@ def count_age_at_child(newLine):
                +" WHERE p1.bornYear <> 0 and p2.bornYear<>0"\
                +" GROUP BY age;"
 
-       out = print_query(s,(),newLine)
+       out = ''
+       for row in run_query(s,()):
+               out = out + print_age_count(row,newLine)
+
        return out
 
 def people_had_child_at_age(age,newLine):
@@ -279,7 +295,7 @@ def people_had_child_at_age(age,newLine):
                 +" ON parents.ID = p1.ID"\
                 +" INNER JOIN people p2"\
                 +" ON parents.parentID = p2.ID"\
-               +" WHERE age = ?"
+               +" WHERE age = ? AND p1.bornYear<>0 AND p2.bornYear<>0"
 
        t = (int(age),)