Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge branch '600672-theme-products'
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed Sep 30, 2010
2 parents cf2ada0 + 7092adf commit 7065f21
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 22 deletions.
30 changes: 19 additions & 11 deletions apps/themes/cron.py
Expand Up @@ -7,7 +7,7 @@
import cronjobs
from textcluster import Corpus, search

from feedback import OS_USAGE, FIREFOX, LATEST_BETAS
from feedback import APP_USAGE, OS_USAGE, LATEST_BETAS
from feedback.models import Opinion
from themes.models import Theme, Item

Expand Down Expand Up @@ -44,23 +44,29 @@ def cluster():
week_ago = datetime.datetime.today() - datetime.timedelta(7)
nowish = datetime.datetime.now() - datetime.timedelta(hours=1)

base_qs = Opinion.objects.filter(locale='en-US', created__gte=week_ago,
version=LATEST_BETAS[FIREFOX])

base_qs = Opinion.objects.filter(locale='en-US', created__gte=week_ago)
log.debug('Beginning clustering')
cluster_by_feeling(base_qs)
cluster_by_product(base_qs)
log.debug('Removing old clusters')
Theme.objects.filter(created__lt=nowish).delete()


def cluster_by_feeling(base_qs):
happy = base_qs.filter(positive=True)
sad = base_qs.filter(positive=False)
cluster_by_platform(happy, 'happy')
cluster_by_platform(sad, 'sad')
def cluster_by_product(qs):
for app in APP_USAGE:
log.debug('Clustering %s(%s)' %
(unicode(app.pretty), LATEST_BETAS[app]))
qs = qs.filter(product=app.id, version=LATEST_BETAS[app])
cluster_by_feeling(qs, app)


def cluster_by_feeling(qs, app):
happy = qs.filter(positive=True)
sad = qs.filter(positive=False)
cluster_by_platform(happy, app, 'happy')
cluster_by_platform(sad, app, 'sad')

def cluster_by_platform(qs, feeling):

def cluster_by_platform(qs, app, feeling):
# We need to create corpii for each platform and manually inspect each
# opinion and put it in the right platform bucket.
for platform in OS_USAGE:
Expand All @@ -69,6 +75,7 @@ def cluster_by_platform(qs, feeling):

if result:
dimensions = {
'product': app.id,
'feeling': feeling,
'platform': platform.short,
}
Expand All @@ -87,6 +94,7 @@ def cluster_by_platform(qs, feeling):
Item(theme=topic, opinion=s['object'],
score=s['similarity']).save()


def cluster_queryset(qs):
seen = {}
c = Corpus(similarity=SIM_THRESHOLD, stopwords=STOPWORDS)
Expand Down
1 change: 1 addition & 0 deletions apps/themes/models.py
Expand Up @@ -9,6 +9,7 @@ class Theme(ModelBase):
opinions = models.ManyToManyField(Opinion, through='Item')
num_opinions = models.IntegerField(default=0, db_index=True)
feeling = models.CharField(max_length=20, db_index=True) # happy or sad
product = models.PositiveSmallIntegerField()
platform = models.CharField(max_length=255, db_index=True)
created = models.DateTimeField(auto_now_add=True, db_index=True)

Expand Down
9 changes: 8 additions & 1 deletion apps/themes/templates/themes/index.html
Expand Up @@ -4,7 +4,14 @@

{% block content %}
<div class="col left">
<form id="filters" class="filters segments block" method="get" action="{{ url('themes') }}">
<form id="filters" class="filters segments block" method="get"
action="{{ url('themes') }}">
<div class="choice">
<h3>{{ _('Product') }}</h3>
<div>
{{ filter_list(products) }}
</div>
</div>
<div class="choice">
<h3>{{ _('Type of Feedback') }}</h3>
<div>
Expand Down
19 changes: 17 additions & 2 deletions apps/themes/views.py
Expand Up @@ -6,7 +6,7 @@
import jingo
from tower import ugettext as _

from feedback import OSES
from feedback import APPS, OSES, FIREFOX, APP_USAGE
from input.decorators import cache_page
from input.helpers import urlparams
from themes.models import Theme
Expand Down Expand Up @@ -55,11 +55,26 @@ def _get_platforms(request, platform):
return platforms


def _get_products(request, product):
products = []
url = request.get_full_path()

for app in APP_USAGE:
f = Filter(urlparams(url, a=app.short), app.pretty, app.pretty,
(product == app.short))
products.append(f)

return products


@cache_page(use_get=True)
def index(request):
"""List the various clusters of data we have."""

qs = Theme.objects.all()
product = request.GET.get('a', FIREFOX.short)
products = _get_products(request, product)
qs = qs.filter(product=APPS[product].id)

sentiment = request.GET.get('s')
sentiments = _get_sentiments(request, sentiment)
Expand All @@ -71,7 +86,7 @@ def index(request):
if platform:
qs = qs.filter(platform=platform)

args = dict(sentiments=sentiments, platforms=platforms)
args = dict(sentiments=sentiments, platforms=platforms, products=products)
page = request.GET.get('page', 1)

if qs:
Expand Down
2 changes: 1 addition & 1 deletion lib/product_details_json/firefox_beta_builds.json
@@ -1 +1 @@
{"ast":{"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"es-CL":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"es-MX":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"gd":{"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"kk":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"ku":{"3.5.12":[],"3.6.9":{"Windows":{"filesize":7.9},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"mn":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":[]},"or":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":8},"OS X":{"filesize":19},"Linux":{"filesize":9.8}}},"rm":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"ta":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":8},"OS X":{"filesize":19},"Linux":{"filesize":9.8}}},"ta-LK":{"3.5.12":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.9":{"Windows":{"filesize":7.9},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}}}
{"ast":{"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"es-CL":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"es-MX":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"gd":{"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.5}}},"kk":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"ku":{"3.5.13":[],"3.6.10":{"Windows":{"filesize":7.9},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"mn":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":[]},"or":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":8},"OS X":{"filesize":19},"Linux":{"filesize":9.8}}},"rm":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":7.8},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}},"ta":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":8},"OS X":{"filesize":19},"Linux":{"filesize":9.8}}},"ta-LK":{"3.5.13":{"Windows":{"filesize":7.6},"OS X":{"filesize":17.4},"Linux":{"filesize":9.2}},"3.6.10":{"Windows":{"filesize":7.9},"OS X":{"filesize":19},"Linux":{"filesize":9.6}}}}
@@ -1 +1 @@
{"1.0rc1":"2004-10-27","1.0rc2":"2004-11-03","1.5rc1":"2005-11-01","1.5rc2":"2005-11-10","1.5rc3":"2005-11-17","2.0b1":"2006-07-12","2.0b2":"2006-08-31","2.0rc1":"2006-09-26","2.0rc2":"2006-10-06","2.0rc3":"2007-10-16","3.0b1":"2007-11-19","3.0b2":"2007-12-18","3.0b3":"2008-02-12","3.0b4":"2008-03-10","3.0b5":"2008-04-02","3.0rc1":"2008-05-16","3.0rc2":"2008-06-03","3.1b1":"2008-08-14","3.1b2":"2008-12-08","3.1b3":"2009-03-12","3.5b4":"2009-04-27","3.5rc2":"2009-06-19","3.5rc3":"2009-06-24","3.6b1":"2009-10-30","3.6b2":"2009-11-10","3.6b3":"2009-11-17","3.6b4":"2009-11-26","3.6b5":"2009-12-17","3.6rc1":"2010-01-08","3.6rc2":"2010-01-17","3.6.3plugin1":"2010-04-08","3.6.4build1":"2010-04-20","3.6.4build3":"2010-05-04","3.6.4build4":"2010-05-14","3.6.4build5":"2010-05-26","3.6.4build6":"2010-05-28","3.6.4build7":"2010-06-14","3.6.7build1":"2010-07-02","4.0b1":"2010-07-06","4.0b2":"2010-07-27","4.0b3":"2010-08-11","4.0b4":"2010-08-24","4.0b5":"2010-09-07"}
{"1.0rc1":"2004-10-27","1.0rc2":"2004-11-03","1.5rc1":"2005-11-01","1.5rc2":"2005-11-10","1.5rc3":"2005-11-17","2.0b1":"2006-07-12","2.0b2":"2006-08-31","2.0rc1":"2006-09-26","2.0rc2":"2006-10-06","2.0rc3":"2007-10-16","3.0b1":"2007-11-19","3.0b2":"2007-12-18","3.0b3":"2008-02-12","3.0b4":"2008-03-10","3.0b5":"2008-04-02","3.0rc1":"2008-05-16","3.0rc2":"2008-06-03","3.1b1":"2008-08-14","3.1b2":"2008-12-08","3.1b3":"2009-03-12","3.5b4":"2009-04-27","3.5rc2":"2009-06-19","3.5rc3":"2009-06-24","3.6b1":"2009-10-30","3.6b2":"2009-11-10","3.6b3":"2009-11-17","3.6b4":"2009-11-26","3.6b5":"2009-12-17","3.6rc1":"2010-01-08","3.6rc2":"2010-01-17","3.6.3plugin1":"2010-04-08","3.6.4build1":"2010-04-20","3.6.4build3":"2010-05-04","3.6.4build4":"2010-05-14","3.6.4build5":"2010-05-26","3.6.4build6":"2010-05-28","3.6.4build7":"2010-06-14","3.6.7build1":"2010-07-02","4.0b1":"2010-07-06","4.0b2":"2010-07-27","4.0b3":"2010-08-11","4.0b4":"2010-08-24","4.0b5":"2010-09-07","4.0b6":"2010-09-14"}
@@ -1 +1 @@
{"1.0.1":"2005-02-24","1.0.2":"2005-03-23","1.0.3":"2005-04-15","1.0.4":"2005-05-11","1.0.5":"2005-07-12","1.0.6":"2005-07-19","1.0.7":"2005-09-20","1.0.8":"2006-04-13","1.5.0.1":"2006-02-01","1.5.0.2":"2006-04-13","1.5.0.3":"2006-05-02","1.5.0.4":"2006-06-01","1.5.0.5":"2006-07-26","1.5.0.6":"2006-08-02","1.5.0.7":"2006-09-14","1.5.0.8":"2006-11-07","1.5.0.9":"2006-12-19","1.5.0.10":"2007-02-23","1.5.0.11":"2007-03-20","1.5.0.12":"2007-05-30","2.0.0.1":"2006-12-19","2.0.0.2":"2007-02-23","2.0.0.3":"2007-03-20","2.0.0.4":"2007-05-30","2.0.0.5":"2007-07-17","2.0.0.6":"2007-07-30","2.0.0.7":"2007-09-18","2.0.0.8":"2007-10-18","2.0.0.9":"2007-11-01","2.0.0.10":"2007-11-26","2.0.0.11":"2007-11-30","2.0.0.12":"2008-02-07","2.0.0.13":"2008-03-25","2.0.0.14":"2008-04-16","2.0.0.15":"2008-07-01","2.0.0.16":"2008-07-15","2.0.0.17":"2008-09-23","2.0.0.18":"2008-11-12","2.0.0.19":"2008-12-16","2.0.0.20":"2008-12-18","3.0.1":"2008-07-16","3.0.2":"2008-09-23","3.0.3":"2008-09-26","3.0.4":"2008-11-12","3.0.5":"2008-12-16","3.0.6":"2009-02-03","3.0.7":"2009-03-04","3.0.8":"2009-03-27","3.0.9":"2009-04-21","3.0.10":"2009-04-27","3.0.11":"2009-06-11","3.0.12":"2009-07-21","3.0.13":"2009-08-03","3.0.14":"2009-09-09","3.0.15":"2009-10-27","3.0.16":"2009-12-15","3.0.17":"2010-01-05","3.0.18":"2010-02-17","3.0.19":"2010-03-30","3.5.1":"2009-07-17","3.5.2":"2009-08-03","3.5.3":"2009-09-09","3.5.4":"2009-10-27","3.5.5":"2009-11-05","3.5.6":"2009-12-15","3.5.7":"2010-01-05","3.5.8":"2010-02-17","3.5.9":"2010-03-30","3.5.10":"2010-06-22","3.5.11":"2010-07-20","3.5.12":"2010-09-07","3.6.2":"2010-03-22","3.6.3":"2010-04-01","3.6.4":"2010-06-22","3.6.6":"2010-06-26","3.6.7":"2010-07-20","3.6.8":"2010-07-23","3.6.9":"2010-09-07"}
{"1.0.1":"2005-02-24","1.0.2":"2005-03-23","1.0.3":"2005-04-15","1.0.4":"2005-05-11","1.0.5":"2005-07-12","1.0.6":"2005-07-19","1.0.7":"2005-09-20","1.0.8":"2006-04-13","1.5.0.1":"2006-02-01","1.5.0.2":"2006-04-13","1.5.0.3":"2006-05-02","1.5.0.4":"2006-06-01","1.5.0.5":"2006-07-26","1.5.0.6":"2006-08-02","1.5.0.7":"2006-09-14","1.5.0.8":"2006-11-07","1.5.0.9":"2006-12-19","1.5.0.10":"2007-02-23","1.5.0.11":"2007-03-20","1.5.0.12":"2007-05-30","2.0.0.1":"2006-12-19","2.0.0.2":"2007-02-23","2.0.0.3":"2007-03-20","2.0.0.4":"2007-05-30","2.0.0.5":"2007-07-17","2.0.0.6":"2007-07-30","2.0.0.7":"2007-09-18","2.0.0.8":"2007-10-18","2.0.0.9":"2007-11-01","2.0.0.10":"2007-11-26","2.0.0.11":"2007-11-30","2.0.0.12":"2008-02-07","2.0.0.13":"2008-03-25","2.0.0.14":"2008-04-16","2.0.0.15":"2008-07-01","2.0.0.16":"2008-07-15","2.0.0.17":"2008-09-23","2.0.0.18":"2008-11-12","2.0.0.19":"2008-12-16","2.0.0.20":"2008-12-18","3.0.1":"2008-07-16","3.0.2":"2008-09-23","3.0.3":"2008-09-26","3.0.4":"2008-11-12","3.0.5":"2008-12-16","3.0.6":"2009-02-03","3.0.7":"2009-03-04","3.0.8":"2009-03-27","3.0.9":"2009-04-21","3.0.10":"2009-04-27","3.0.11":"2009-06-11","3.0.12":"2009-07-21","3.0.13":"2009-08-03","3.0.14":"2009-09-09","3.0.15":"2009-10-27","3.0.16":"2009-12-15","3.0.17":"2010-01-05","3.0.18":"2010-02-17","3.0.19":"2010-03-30","3.5.1":"2009-07-17","3.5.2":"2009-08-03","3.5.3":"2009-09-09","3.5.4":"2009-10-27","3.5.5":"2009-11-05","3.5.6":"2009-12-15","3.5.7":"2010-01-05","3.5.8":"2010-02-17","3.5.9":"2010-03-30","3.5.10":"2010-06-22","3.5.11":"2010-07-20","3.5.12":"2010-09-07","3.5.13":"2010-09-15","3.6.2":"2010-03-22","3.6.3":"2010-04-01","3.6.4":"2010-06-22","3.6.6":"2010-06-26","3.6.7":"2010-07-20","3.6.8":"2010-07-23","3.6.9":"2010-09-07","3.6.10":"2010-09-15"}

0 comments on commit 7065f21

Please sign in to comment.