Message info
 
To:wikimedia-commits@lists.wikimedia.org From:rfaulk@svn.wikimedia.org Subject:[Wikimedia-commits] SVN: [1587] trunk/community-analysis Date:Thu, 05 Apr 2012 20:58:26 +0000
 

http://www.mediawiki.org/wiki/Special:Code/Wikimedia/1587

Revision: 1587
Author: rfaulk
Date: 2012-04-05 20:58:26 +0000 (Thu, 05 Apr 2012)
Log Message:
-----------
Built view for 1000 editor threshold

Modified Paths:
--------------
trunk/community-analysis/sandbox/src/editor_threshold_notify.py
trunk/community-analysis/web_interface/templates/index.html
trunk/community-analysis/web_interface/urls.py
trunk/community-analysis/web_interface/views.py

Added Paths:
-----------
trunk/community-analysis/web_interface/templates/thousandth_edit.html

Modified: trunk/community-analysis/sandbox/src/editor_threshold_notify.py
===================================================================
--- trunk/community-analysis/sandbox/src/editor_threshold_notify.py 2012-04-05 20:32:41 UTC (rev 1586)
+++ trunk/community-analysis/sandbox/src/editor_threshold_notify.py 2012-04-05 20:58:26 UTC (rev 1587)
@@ -28,17 +28,18 @@
logging.basicConfig(level=logging.DEBUG, stream=LOGGING_STREAM, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%b-%d %H:%M:%S')

# SQL query to return editor count
- sql = 'select count(*) from edit_count_live_backup where ec_namespace = 0 and ec_num_edits >= 1000'
+ sql = 'select count(*) from staeiou.edit_count_live_backup where ec_namespace = 0 and ec_num_edits >= 1000'
sql_insert = 'insert into rfaulk.thousandth_edit values ("%(user_name)s", "%(timestamp)s")'


dl = DL.DataLoader(db='db42')
num_wikipedians = dl.execute_SQL(sql)[0][0]
- at_1000 = get_editors_at_1000()
+ at_1000, at_1000_str = get_editors_at_1000()

while(1):

logging.info('Are there any new editors out there???? I see %s Wikipedians....' % str(num_wikipedians))
+ logging.info('Editors at 1000 edits: ' + at_1000_str)

num_wikipedians_old = num_wikipedians
num_wikipedians = dl.execute_SQL(sql)[0][0]
@@ -56,32 +57,38 @@
os.system('mplayer /home/rfaulkner/trunk/projects/Sandbox/data/tos_transporter.wav')
logging.info('Beam them up Scotty!! Now I see %s :)' % num_wikipedians)

- new_at_1000 = get_editors_at_1000()
+ new_at_1000 = get_editors_at_1000()[0]

- for user in find_new_elems(at_1000, new_at_1000):
+ new_elems = find_new_elems(at_1000, new_at_1000)
+ for user in new_elems:
dl.execute_SQL(sql_insert % {'user_name' : user, 'timestamp' : now})

at_1000 = new_at_1000
else:
- at_1000 = get_editors_at_1000() # keep an accurate list of editors at 1000
+ at_1000, at_1000_str = get_editors_at_1000() # keep an accurate list of editors at 1000

time.sleep(60)

return 0

+
""" Get a list of editors reaching the 1000 edit threshold """
def get_editors_at_1000():

dl = DL.DataLoader(db='db42')
- sql_get_1000th = 'select ec_user_name from edit_count_live_backup where ec_namespace = 0 and ec_num_edits = 1000'
+ sql_get_1000th = 'select ec_user_name from staeiou.edit_count_live_backup where ec_namespace = 0 and ec_num_edits = 1000'
res = dl.execute_SQL(sql_get_1000th)

at_1000 = list()
+ at_1000_str = '('

for row in res:
at_1000.append(row[0])
-
- return at_1000
+ at_1000_str = "".join([at_1000_str,row[0],', '])
+
+ at_1000_str = "".join([at_1000_str[:-2],')'])
+
+ return at_1000, at_1000_str


""" give a new and an old list find the elements of the new list not in the old one """

Modified: trunk/community-analysis/web_interface/templates/index.html
===================================================================
--- trunk/community-analysis/web_interface/templates/index.html 2012-04-05 20:32:41 UTC (rev 1586)
+++ trunk/community-analysis/web_interface/templates/index.html 2012-04-05 20:58:26 UTC (rev 1587)
@@ -13,6 +13,12 @@
<div class="spacer"></div>
<div class="spacer"></div>

+1000 Edit Threshold - <a href="/thousandth_edit">link</a>
+
+<div class="spacer"></div>
+<div class="spacer"></div>
+
+
<h3><i>February 29th, 2012 - Huggle Experimentation</i></h3><br>

<p>Below are plots depicting some metrics from a subset of the Huggle experiments that were run by the Community Department at the Wikimedia Foundation.

Added: trunk/community-analysis/web_interface/templates/thousandth_edit.html
===================================================================
--- trunk/community-analysis/web_interface/templates/thousandth_edit.html (rev 0)
+++ trunk/community-analysis/web_interface/templates/thousandth_edit.html 2012-04-05 20:58:26 UTC (rev 1587)
@@ -0,0 +1,16 @@
+
+{% extends "base.html" %}
+{% block content %}
+
+<h1>Editors at the time of their 1000th edit to an article:</h1>
+<div class="spacer"></div>
+
+<center>{{html|safe}}</center>
+
+<br><br>
+<u>Go to:</u>
+<br><br>
+<a href="/">Home</a>
+<br>
+
+{% endblock %}
\ No newline at end of file

Modified: trunk/community-analysis/web_interface/urls.py
===================================================================
--- trunk/community-analysis/web_interface/urls.py 2012-04-05 20:32:41 UTC (rev 1586)
+++ trunk/community-analysis/web_interface/urls.py 2012-04-05 20:58:26 UTC (rev 1587)
@@ -9,4 +9,5 @@
urlpatterns = patterns('',
(r'^$', projSet.__web_app_module__ + '.views.index'),
(r'^active_editors$', projSet.__web_app_module__ + '.views.active_editors'),
+ (r'^thousandth_edit$', projSet.__web_app_module__ + '.views.thousandth_edit'),
)

Modified: trunk/community-analysis/web_interface/views.py
===================================================================
--- trunk/community-analysis/web_interface/views.py 2012-04-05 20:32:41 UTC (rev 1586)
+++ trunk/community-analysis/web_interface/views.py 2012-04-05 20:58:26 UTC (rev 1587)
@@ -13,6 +13,7 @@
from django.template import RequestContext
from django.shortcuts import render_to_response

+import classes.DataLoader as DL
import classes.DataCaching as DC
import classes.DataReporting as DR
import classes.Helper as Help
@@ -42,33 +43,39 @@

# Retrieve cached data

- cache = DC.ActiveEditorsCaching()
+ cache = DC.ActiveEditorsCaching()
+ cache.open_serialized_obj()
+
cache_keys = cache._serialized_obj_.keys()
-
+ cache_keys.sort()

# Format the Data

dr = DR.DataReporting()

data = list()
- counts = list()
- times = list()
- timestamps = list()
+ counts = dict()
+ times = dict()

- for key in cache_keys:
- counts.append(cache._serialized_obj_[key])
- timestamps.append(key)
-
- datetime_object = TP.timestamp_to_obj(key + ' 00:00:00', 2)
- times.append(calendar.timegm(datetime_object.timetuple()) * 1000)
+ total_data_points = 6

- counts = {'Active Editors' : counts}
- # times = {'Active Editors' : range(len(timestamps))}
- times = {'Active Editors' : times}
- # times = {'Active Editors' : range(20)}
-
- logging.info('active_editors view :: counts:\n\n%s\n' % counts)
- logging.info('active_editors view :: times:\n\n%s\n' % times)
+ for key in cache_keys[-total_data_points:]:
+ for ns_key in cache._serialized_obj_[key]:
+
+ new_key = 'Namespace %s' % str(ns_key)
+
+ try:
+ counts[new_key].append(int(cache._serialized_obj_[key][ns_key]))
+ except:
+ counts[new_key] = list()
+ times[new_key] = list()
+ counts[new_key].append(int(cache._serialized_obj_[key][ns_key]))
+
+ datetime_object = TP.timestamp_to_obj(key, 2)
+ times[new_key].append(calendar.timegm(datetime_object.timetuple()) * 1000)
+
+ # logging.info('active_editors view :: counts:\n\n%s\n' % counts)
+ # logging.info('active_editors view :: times:\n\n%s\n' % times)

dr._counts_ = counts
dr._times_ = times
@@ -79,8 +86,22 @@

logging.info('active_editors view :: composed data:\n\n%s\n' % dict_param)

- dict_param['start_time'] = timestamps[0]
- dict_param['end_time'] = timestamps[-1]

+ dict_param['start_time'] = cache_keys[0]
+ dict_param['end_time'] = cache_keys[-1]
+
return render_to_response('active_editor_metrics.html', dict_param, context_instance=RequestContext(request))

+
+"""
+ Table of editors reaching the 1000 edit threshold
+"""
+def thousandth_edit(request):
+
+ dl = DL.DataLoader(db='db42')
+ data = dl.execute_SQL('select * from rfaulk.thousandth_edit')
+ html = DR.DataReporting()._write_html_table(data, ["User Name", "Time of 1000th Edit"])
+
+ return render_to_response('thousandth_edit.html', {'html' : html}, context_instance=RequestContext(request))
+
+
\ No newline at end of file


_______________________________________________
Wikimedia-commits mailing list
Wikimedia-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikimedia-commits