<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -23,11 +23,8 @@ $PYTHONPATH python /path/to/repo/djangopeoplenet/manage.py runserver
 
 TODO
 cleanup imports
-simplify QS reduce given QS.none
 
 
 404s:
 	je.gif
 	aq.gif
-
-rewrite raw sql using aggregates, where possible.</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -26,27 +26,7 @@ RESERVED_USERNAMES = set((
 
 class CountryManager(models.Manager):
     def top_countries(self):
-        # Returns populated countries in order of population
-        from django.db import connection
-        cursor = connection.cursor()
-        cursor.execute(&quot;&quot;&quot;
-            SELECT
-                djangopeople_country.id, count(*) AS peoplecount
-            FROM
-                djangopeople_djangoperson, djangopeople_country
-            WHERE
-                djangopeople_country.id = djangopeople_djangoperson.country_id
-            GROUP BY country_id
-            ORDER BY peoplecount DESC
-        &quot;&quot;&quot;)
-        rows = cursor.fetchall()
-        found = self.in_bulk([r[0] for r in rows])
-        countries = []
-        for row in rows:
-            country = found[row[0]]
-            country.peoplecount = row[1]
-            countries.append(country)
-        return countries
+        return self.get_query_set().order_by('-num_people')
 
 class Country(models.Model):
     # Longest len('South Georgia and the South Sandwich Islands') = 44
@@ -78,28 +58,7 @@ class Country(models.Model):
     
     def top_regions(self):
         # Returns populated regions in order of population
-        from django.db import connection
-        cursor = connection.cursor()
-        cursor.execute(&quot;&quot;&quot;
-            SELECT
-                djangopeople_region.id, count(*) AS peoplecount
-            FROM
-                djangopeople_djangoperson, djangopeople_region
-            WHERE
-                djangopeople_region.id = djangopeople_djangoperson.region_id
-            AND
-                djangopeople_region.country_id = %d
-            GROUP BY djangopeople_djangoperson.region_id
-            ORDER BY peoplecount DESC
-        &quot;&quot;&quot; % self.id)
-        rows = cursor.fetchall()
-        found = Region.objects.in_bulk([r[0] for r in rows])
-        regions = []
-        for row in rows:
-            region = found[row[0]]
-            region.peoplecount = row[1]
-            regions.append(region)
-        return regions
+        return self.region_set.order_by('-num_people')
     
     class Meta:
         ordering = ('name',)</diff>
      <filename>djangopeople/models.py</filename>
    </modified>
    <modified>
      <diff>@@ -42,6 +42,8 @@
     &lt;/div&gt;
     &lt;div class=&quot;header content&quot;&gt;
         {% block header %}&lt;h1&gt;Django People&lt;/h1&gt;{% endblock %}
+        {% block tagline %}&lt;h2 class=&quot;tagline&quot;&gt;Discover users of the &lt;a href=&quot;http://www.djangoproject.com/&quot;&gt;Django Web framework&lt;/a&gt; near you&lt;/h2&gt;{% endblock %}
+        
     &lt;/div&gt;
 {% block map %}{% endblock %}
     &lt;div class=&quot;content&quot;&gt;</diff>
      <filename>djangopeople/templates/base.html</filename>
    </modified>
    <modified>
      <diff>@@ -91,7 +91,7 @@ window.onload = function() {
         &lt;ul class=&quot;detailsList split&quot;&gt;
             {% for region in regions %}
             &lt;li&gt;
-                {% if region.flag %}&lt;a href=&quot;/{{ country.iso_code|lower }}/{{ region.code|lower }}/&quot; class=&quot;nobg&quot;&gt;&lt;img src=&quot;{% thumbnail region.flag 16x11 crop %}&quot; alt=&quot;{{ region }}&quot; title=&quot;{{ region }}&quot;&gt;&lt;/a&gt; {% endif %}&lt;a href=&quot;/{{ country.iso_code|lower }}/{{ region.code|lower }}/&quot;&gt;&lt;strong&gt;{{ region }}&lt;/strong&gt;&lt;/a&gt; {{ region.peoplecount }} {% ifequal region.peoplecount 1 %}person{% else %}people{% endifequal %}
+                {% if region.flag %}&lt;a href=&quot;/{{ country.iso_code|lower }}/{{ region.code|lower }}/&quot; class=&quot;nobg&quot;&gt;&lt;img src=&quot;{% thumbnail region.flag 16x11 crop %}&quot; alt=&quot;{{ region }}&quot; title=&quot;{{ region }}&quot;&gt;&lt;/a&gt; {% endif %}&lt;a href=&quot;/{{ country.iso_code|lower }}/{{ region.code|lower }}/&quot;&gt;&lt;strong&gt;{{ region }}&lt;/strong&gt;&lt;/a&gt; {{ region.num_people }} {% ifequal region.num_people 1 %}person{% else %}people{% endifequal %}
             &lt;/li&gt;
             {% endfor %}
         &lt;/ul&gt;</diff>
      <filename>djangopeople/templates/country.html</filename>
    </modified>
    <modified>
      <diff>@@ -89,9 +89,8 @@ var loading = false;
 {% endblock %}
 
 {% block content %}
-    &lt;p class=&quot;mapnote&quot;&gt;Showing {{ recent_people|length }} recent signups (out of {{ total_people }}){% if user.is_anonymous %} - if you're a Django developer, why not &lt;a href=&quot;/signup/&quot;&gt;add yourself&lt;/a&gt; to the site?{% endif %}&lt;/p&gt;
-        &lt;h2 class=&quot;tagline&quot;&gt;Discover users of the &lt;a href=&quot;http://www.djangoproject.com/&quot;&gt;Django Web framework&lt;/a&gt; near you&lt;/h2&gt;
-        &lt;!-- &lt;ul class=&quot;detailsList split&quot;&gt;
+    &lt;p class=&quot;mapnote&quot;&gt;Showing {{ recent_people_limited|length }} recent signups (out of {{ total_people }}){% if user.is_anonymous %} - if you're a Django developer, why not &lt;a href=&quot;/signup/&quot;&gt;add yourself&lt;/a&gt; to the site?{% endif %}&lt;/p&gt;
+        &lt;ul class=&quot;detailsList split&quot;&gt;
             {% for person in recent_people_limited %}
             &lt;li&gt;
                 &lt;img src=&quot;{% if person.photo %}{% thumbnail person.photo 40x40 crop %}{% else %}/static/img/person_small_blank.png{% endif %}&quot; alt=&quot;{{ person }}&quot; class=&quot;main&quot;&gt;
@@ -100,11 +99,11 @@ var loading = false;
                 
             &lt;/li&gt;
             {% endfor %}
-        &lt;/ul&gt; --&gt;
+        &lt;/ul&gt;
         &lt;ul class=&quot;detailsList split&quot;&gt;
             {% for country in countries %}
             &lt;li&gt;
-                &lt;a href=&quot;/{{ country.iso_code|lower }}/&quot; class=&quot;nobg&quot;&gt;&lt;img src=&quot;/static/img/flags/{{ country.iso_code|lower }}.gif&quot; alt=&quot;{{ country }}&quot; title=&quot;{{ country }}&quot;&gt;&lt;/a&gt; &lt;a href=&quot;/{{ country.iso_code|lower }}/&quot;&gt;&lt;strong&gt;{{ country }}&lt;/strong&gt;&lt;/a&gt; {{ country.peoplecount }} {% ifequal country.peoplecount 1 %}person{% else %}people{% endifequal %}
+                &lt;a href=&quot;/{{ country.iso_code|lower }}/&quot; class=&quot;nobg&quot;&gt;&lt;img src=&quot;/static/img/flags/{{ country.iso_code|lower }}.gif&quot; alt=&quot;{{ country }}&quot; title=&quot;{{ country }}&quot;&gt;&lt;/a&gt; &lt;a href=&quot;/{{ country.iso_code|lower }}/&quot;&gt;&lt;strong&gt;{{ country }}&lt;/strong&gt;&lt;/a&gt; {{ country.num_people }} {% ifequal country.num_people 1 %}person{% else %}people{% endifequal %}
             &lt;/li&gt;
             {% endfor %}
         &lt;/ul&gt;</diff>
      <filename>djangopeople/templates/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -36,10 +36,9 @@ def must_be_owner(view):
     return inner
 
 def index(request):
-    recent_people = list(DjangoPerson.objects.all().select_related().order_by('-id')[:100])
+    recent_people_limited = DjangoPerson.objects.all().select_related().order_by('-id')[:4]
     return render(request, 'index.html', {
-        'recent_people': recent_people,
-        'recent_people_limited': recent_people[:4],
+        'recent_people_limited': recent_people_limited,
         'total_people': DjangoPerson.objects.count(),
         'api_key': settings.GOOGLE_MAPS_API_KEY,
         'countries': Country.objects.top_countries(),</diff>
      <filename>djangopeople/views.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>86b999e7bbd7228e6e4507b613a3e809ae2af4c0</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Dunck</name>
    <email>jdunck@gmail.com</email>
  </author>
  <url>http://github.com/simonw/djangopeople.net/commit/50a37e274f6c0170a1dbe5cabaaf2f6fc6359fc6</url>
  <id>50a37e274f6c0170a1dbe5cabaaf2f6fc6359fc6</id>
  <committed-date>2009-09-12T14:22:34-07:00</committed-date>
  <authored-date>2009-09-12T03:58:43-07:00</authored-date>
  <message>Removed spurious cursor.executes, since num_peopel is denormalized.

Signed-off-by: Simon Willison &lt;simon@simonwillison.net&gt;</message>
  <tree>2c8d3e872d7b42880b70e0ecd0c6f48e332d9798</tree>
  <committer>
    <name>Simon Willison</name>
    <email>simon@simonwillison.net</email>
  </committer>
</commit>
