community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1746029 - in /comdev/nearby_people: data/ local_settings.py.example nearby/dates.py nearby/foaf.py nearby/views.py readme.txt templates/map.html templates/years_map.html urls.py
Date Sun, 29 May 2016 16:13:19 GMT
Author: nick
Date: Sun May 29 16:13:19 2016
New Revision: 1746029

URL: http://svn.apache.org/viewvc?rev=1746029&view=rev
Log:
Use a ldap export to find when accounts were created, prepare for filtering

Added:
    comdev/nearby_people/nearby/dates.py
    comdev/nearby_people/templates/years_map.html
Modified:
    comdev/nearby_people/data/   (props changed)
    comdev/nearby_people/local_settings.py.example
    comdev/nearby_people/nearby/foaf.py
    comdev/nearby_people/nearby/views.py
    comdev/nearby_people/readme.txt
    comdev/nearby_people/templates/map.html
    comdev/nearby_people/urls.py

Propchange: comdev/nearby_people/data/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun May 29 16:13:19 2016
@@ -5,3 +5,4 @@ info
 people
 project
 local-outreach
+*.ldif

Modified: comdev/nearby_people/local_settings.py.example
URL: http://svn.apache.org/viewvc/comdev/nearby_people/local_settings.py.example?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/local_settings.py.example (original)
+++ comdev/nearby_people/local_settings.py.example Sun May 29 16:13:19 2016
@@ -13,6 +13,9 @@ COMDEV_DOAP = os.path.join(BASE_PATH, "d
 SPEAKERS_DOAP = os.path.join(BASE_PATH, "data/local-outreach/ApacheSpeakers.rdf")
 PEOPLE_FOAF_PATH = os.path.join(BASE_PATH, "data/info/")
 
+# This should point to where the LDAP Search result of uids+createTimestamps is
+UID_CREATED_LDIF = os.path.join(BASE_PATH, "data/uid-created.ldif")
+
 # How often to reload all the DOAP/FOAF files, in hours
 FOAF_REFRESH_HOURS = 2
 

Added: comdev/nearby_people/nearby/dates.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/dates.py?rev=1746029&view=auto
==============================================================================
--- comdev/nearby_people/nearby/dates.py (added)
+++ comdev/nearby_people/nearby/dates.py Sun May 29 16:13:19 2016
@@ -0,0 +1,82 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+# Uses an LDIF file from a LDAP search / export to track account ages
+
+from settings import UID_CREATED_LDIF
+import datetime
+import sys,os
+
+LDAP_MASS_IMPORTED_BEFORE = datetime.date(2009,5,19)
+
+class UIDDates(object):
+    def __init__(self):
+        self.dates = {}
+
+    def get_earliest_year(self):
+        return LDAP_MASS_IMPORTED_BEFORE.year
+
+    def get_latest_year(self):
+        self.ensure_data()
+        year = self.get_earliest_year()
+        for d in self.dates.values():
+            if d.year > year:
+               year = d.year
+        return year
+
+    def get_year(self, uid):
+        self.ensure_data()
+        d = self.dates.get(uid, None)
+        if d:
+            return d.year
+        return None
+
+    def decorate(self, people):
+        self.ensure_data()
+        if_none_year = self.get_latest_year()
+        for p in people:
+            uid = p["uid"]
+            if self.dates.has_key(uid):
+                p["year"] = self.dates[uid].year
+            else:
+                # Assume it's a newer account than our LDIF
+                p["year"] = if_none_year
+
+    def ensure_data(self):
+        # Changes infrequently and manually, just load when first needed
+        if not self.dates:
+            self._refresh()
+    def _refresh(self):
+        if not os.path.exists(UID_CREATED_LDIF):
+            sys.stderr.write("Missing UID/Created LDIF file: %s\n" % UID_CREATED_LDIF)
+        try:
+            person = {}
+            self.dates = {}
+            ldif = open(UID_CREATED_LDIF, "r")
+            for line in ldif.readlines():
+                if not line:
+                    if "uid" in person and "created" in person:
+                        self.dates[person["uid"]] = person["created"]
+                    person = {}
+                elif ":" in line:
+                    k, v = [x.strip() for x in line.split(":")][0:2]
+                    if k == "createTimestamp":
+                         k = "created"
+                         ymd = [int(x) for x in (v[0:4],v[4:6],v[6:8])]
+                         v = datetime.date(*ymd)
+        except IOError, e:
+             sys.stderr.write("Unable to process created LDIF file: %s\n" % e)

Modified: comdev/nearby_people/nearby/foaf.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/foaf.py?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/nearby/foaf.py (original)
+++ comdev/nearby_people/nearby/foaf.py Sun May 29 16:13:19 2016
@@ -91,7 +91,6 @@ class FOAF(object):
             uri = foaf.getAttribute("rdf:resource")
             if not uri:
                 continue
-            #print uri
 
             people_rel_uri = uri
             people_rel_uri = people_rel_uri.replace(PEOPLE_FOAF_NAMESPACE,"")

Modified: comdev/nearby_people/nearby/views.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/views.py?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/nearby/views.py (original)
+++ comdev/nearby_people/nearby/views.py Sun May 29 16:13:19 2016
@@ -19,6 +19,7 @@ from django.http import HttpResponseRedi
 from settings import COMDEV_DOAP, SPEAKERS_DOAP, GMAPS_KEY, GEONAMES_USERNAME
 
 from nearby_people.nearby.foaf import *
+from nearby_people.nearby.dates import *
 from nearby_people.nearby.forms import *
 from nearby_people.nearby.shortcuts import *
 
@@ -34,6 +35,7 @@ except ImportError:
 comdev_foaf = FOAF(COMDEV_DOAP)
 speakers_foaf = FOAF(SPEAKERS_DOAP)
 all_public_foaf = ListingFOAF(PEOPLE_FOAF_PATH)
+uid_dates = UIDDates()
 
 def welcome(request):
    form = PlaceForm()
@@ -147,3 +149,15 @@ def all_people(request):
    "Map of all committers with public locations"
    data = { "gmaps_key": GMAPS_KEY, "people": all_public_foaf.get_all() }
    return render(request, "map.html", data)
+
+def people_years(request):
+   "Map of all committers with public locations, by when they joined"
+   people = all_public_foaf.get_all()
+   uid_dates.decorate(people)
+   data = { 
+      "gmaps_key": GMAPS_KEY, 
+      "people": people,
+      "start_year": uid_dates.get_earliest_year(),
+      "end_year": uid_dates.get_latest_year()
+   }
+   return render(request, "years_map.html", data)

Modified: comdev/nearby_people/readme.txt
URL: http://svn.apache.org/viewvc/comdev/nearby_people/readme.txt?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/readme.txt (original)
+++ comdev/nearby_people/readme.txt Sun May 29 16:13:19 2016
@@ -12,7 +12,9 @@ subprojects/CommunityDevelopment.rdf and
 If you're interested in having a play, it's a Django (python) web app. Just check it out
[1] and
 our subproject DOAP files [3] (these need to be checked out to the same directory, or you
 need to update local_settings.py). You'll also need to check out the Apache Foaf files from
[2], 
-either put [3] into data/people or edit PEOPLE_FOAF_PATH in local_settings.py accordingly.

+either put [3] into data/people or edit PEOPLE_FOAF_PATH in local_settings.py accordingly.
Finally,
+you need to run "ldapsearch '' uid createTimestamp" on a suitable ASF box and put that as

+data/uid-created.ldif so that the map-by-time functionality knows about account dates
 
 Copy local_settings.py.example to local_settings.py and tell it where the checkouts are.

 Finally, do ./manage.py runserver and then http://localhost:8000/ will be it.

Modified: comdev/nearby_people/templates/map.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/map.html?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/templates/map.html (original)
+++ comdev/nearby_people/templates/map.html Sun May 29 16:13:19 2016
@@ -92,4 +92,11 @@ $(document).ready(function(){
  which will allow people to search for you <a href="/">here</a>.
 </p>
 
+<br />
+
+<p>To see somewhat how this map has changed over time, please see the
+ <a href="/map/years/">map of current public locations, filtered by the year
+ someone became a committer</a>.
+</p>
+
 {% endblock %}

Added: comdev/nearby_people/templates/years_map.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/years_map.html?rev=1746029&view=auto
==============================================================================
--- comdev/nearby_people/templates/years_map.html (added)
+++ comdev/nearby_people/templates/years_map.html Sun May 29 16:13:19 2016
@@ -0,0 +1,83 @@
+{% extends "base_map.html" %}
+{% load distances %}
+{% load emails %}
+
+{% block title %}- Public Committers Locations by Year{% endblock %}
+{% block heading %}Apache Public Committers Years Map{% endblock %}
+{% block bodyclass %}people{% endblock %}
+{% block initmap %}
+<script type="text/javascript" charset="utf-8">
+<!--
+$(document).ready(function(){
+	if (GBrowserIsCompatible()) {
+		map = new GMap2(document.getElementById('map'));
+		map.addControl(new GLargeMapControl());
+
+      map.setZoom(2);
+      map.panTo(new GLatLng(20, 0));
+
+      // Add our markers
+      {% for person in people %}
+            var projectNames = new Array();
+            {% for project in person.projects %}
+                projectNames.push("{{project.name}}");
+            {% endfor %}
+            marker = createMarker("{{person.name}}",{{person.latitude}},
+                         {{person.longitude}},"{{person.link}}", projectNames,
+                         "{{person.avatar}}","{{person.email|emailformat}}");
+            map.addOverlay(marker);
+            markers["{{person.uid}}"] = marker;
+      {% endfor %}
+   }
+});
+//-->
+</script>
+{% endblock %}
+{% block content %}
+
+<p>This map shows location the <i>current</i> location of those ASF
+ committers who have chosen to publically share their location in their 
+ FOAF files. It allows you to <i>somewhat</i> see how this has changed
+ over time. Caveats below!.</p>
+
+<p><b>TODO: Filtering</b></p>
+
+<div id="map" class="col1map"></div>
+
+<br clear="all" />
+<br /><br /><br />
+
+<p>Some notes:</p>
+<ul>
+ <li>This only shows the location of those ASF committers who have chosen
+  to create + store a FOAF file with the foundation, and include a public
+  location in it. That's currently only about 15% of committers</li>
+ <li>This only shows the current location, not the historic one. If someone
+  joined in 2010 and was living in Paris, but today lives in Zurich, then
+  filtering for 2010 will show Zurich not Paris</li>
+ <li>Because of limitations in the data source used, we can't identify
+  joining dates before {{start_year}}, only that it happened on-or-before
+  then.</li>
+</ul>
+
+<p>This map is updated every few hours based on committer FOAF files
+ with locations in. If you're an ASF committer and you'd like to be
+ shown here, please see
+ <a href="http://web.archive.org/web/20160123121801/https://people.apache.org/foaf/index.html">this
archived page</a>
+ for details on what your FOAF file needs to contain and where it needs
+ to live.</p>
+<p>If you are interested, you can also list yourself as a
+ <a href="http://community.apache.org/localmentors.html">Local Mentor</a>
+ or as a 
+ <a href="http://community.apache.org/speakers/speakers.html">Local Speaker</a>,
+ which will allow people to search for you <a href="/">here</a>.
+</p>
+
+<br />
+
+<p>To see somewhat how this map has changed over time, please see the
+ <a href="/map/years/">map of current public locations, filtered by the year
+ someone became a committer</a>.
+</p>
+
+{% endblock %}

Modified: comdev/nearby_people/urls.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/urls.py?rev=1746029&r1=1746028&r2=1746029&view=diff
==============================================================================
--- comdev/nearby_people/urls.py (original)
+++ comdev/nearby_people/urls.py Sun May 29 16:13:19 2016
@@ -34,8 +34,10 @@ urlpatterns = patterns('',
 	(r'^find_people_json/$', 'nearby_people.nearby.views.find_people_json'),
 
    # Replacement for https://people.apache.org/map.html
-	(r'^map/$',     'nearby_people.nearby.views.all_people'),
-	(r'^map.html$', 'nearby_people.nearby.views.all_people'),
+	(r'^map/$',       'nearby_people.nearby.views.all_people'),
+	(r'^map.html$',   'nearby_people.nearby.views.all_people'),
+   # Map of all committers, filterable by when they joined
+	(r'^map/years/$', 'nearby_people.nearby.views.people_years'),
 
     # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
     # to INSTALLED_APPS to enable admin documentation:



Mime
View raw message