Fixed sql statement generating wrong statistics (bug 631686)
This commit is contained in:
Родитель
509cf5a602
Коммит
c4259b20c0
|
@ -0,0 +1,108 @@
|
|||
[
|
||||
{
|
||||
"pk": 116367,
|
||||
"model": "versions.version",
|
||||
"fields": {
|
||||
"created": "2010-08-27 21:15:27",
|
||||
"modified": "2010-08-27 21:15:27",
|
||||
"version": "0.1",
|
||||
"addon": 222197
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 1349882,
|
||||
"model": "translations.translation",
|
||||
"fields": {
|
||||
"localized_string_clean": "We always thrive to perform better. Moreover this project is still in its Beta version, so we are doing a little more than our Best to make it more user friendly, easier to use and valuable. For feedback, bugs, comments, compliments or any type of communication, feel free to contact us at quicklinkto@googlemail.com or write a review here. We will be more than happy to reply.",
|
||||
"created": "2010-08-28 23:22:30",
|
||||
"locale": "en-US",
|
||||
"id": 1277089,
|
||||
"localized_string": "We always thrive to perform better. Moreover this project is still in its Beta version, so we are doing a little more than our Best to make it more user friendly, easier to use and valuable. For feedback, bugs, comments, compliments or any type of communication, feel free to contact us at quicklinkto@googlemail.com or write a review here. We will be more than happy to reply."
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 97656,
|
||||
"model": "files.file",
|
||||
"fields": {
|
||||
"status": 1,
|
||||
"codereview": false,
|
||||
"no_restart": false,
|
||||
"hash": "sha256:1a496e35dd56fb377bb3dea306e285f0a3ff3e684fb758aaa04018e86da2ffaa",
|
||||
"created": "2010-08-27 21:15:32",
|
||||
"jetpack": false,
|
||||
"modified": "2010-08-27 21:15:32",
|
||||
"filename": "quick_link_to_the_world-0.1-fx.xpi",
|
||||
"platform": 1,
|
||||
"version": 116367,
|
||||
"datestatuschanged": "2010-08-27 21:14:17",
|
||||
"size": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 222197,
|
||||
"model": "addons.addon",
|
||||
"fields": {
|
||||
"dev_agreement": true,
|
||||
"last_updated": "2010-08-27 21:15:32",
|
||||
"view_source": false,
|
||||
"enable_thankyou": false,
|
||||
"total_downloads": 9,
|
||||
"developer_comments": 1277089,
|
||||
"_current_version": 116367,
|
||||
"average_daily_downloads": 9,
|
||||
"admin_review_type": 1,
|
||||
"trusted": false,
|
||||
"total_contributions": "0.00",
|
||||
"binary": false,
|
||||
"guid": "qlt@vik.josh",
|
||||
"weekly_downloads": 0,
|
||||
"support_url": 1277096,
|
||||
"disabled_by_user": false,
|
||||
"paypal_id": "",
|
||||
"average_rating": 0.0,
|
||||
"wants_contributions": false,
|
||||
"average_daily_users": 0,
|
||||
"bayesian_rating": 0.0,
|
||||
"share_count": 0,
|
||||
"homepage": 1276308,
|
||||
"support_email": 1276309,
|
||||
"public_stats": false,
|
||||
"status": 10,
|
||||
"description": 1276307,
|
||||
"default_locale": "en-US",
|
||||
"get_satisfaction_product": "",
|
||||
"prerelease": false,
|
||||
"admin_review": false,
|
||||
"slug": "quick-link-to-the-world-url",
|
||||
"external_software": false,
|
||||
"highest_status": 1,
|
||||
"get_satisfaction_company": "",
|
||||
"name": 1276305,
|
||||
"created": "2010-08-27 21:15:25",
|
||||
"type": 1,
|
||||
"icon_type": "image/png",
|
||||
"annoying": 0,
|
||||
"modified": "2010-08-28 23:35:42",
|
||||
"summary": 1276306,
|
||||
"site_specific": false,
|
||||
"total_reviews": 0,
|
||||
"nomination_date": "2010-08-27 21:40:41"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 32470,
|
||||
"model": "files.approval",
|
||||
"fields": {
|
||||
"created": "2010-08-28 19:15:33",
|
||||
"user": 5497308,
|
||||
"modified": "2010-08-28 19:15:33",
|
||||
"reviewtype": "nominated",
|
||||
"applications": "",
|
||||
"comments": "Dear add-on developer,\r\n\r\nIt is unclear to us at this time if your add-on will be useful for a general audience so that it warrants public listing. We're rejecting your nomination, but encourage you to promote your listing so that it garners more active users and user reviews. You may re-nominate your add-on once there is more proof of its usefulness.\r\n\r\nThank you.",
|
||||
"file": 97656,
|
||||
"action": 1,
|
||||
"os": "",
|
||||
"addon": 222197
|
||||
}
|
||||
}
|
||||
]
|
|
@ -27,7 +27,7 @@
|
|||
{% for row in reviews_total: %}
|
||||
<tr>
|
||||
<td>{{ row['user__display_name'] }}</td>
|
||||
<td class="int">{{ row['approval__count']|numberfmt }}</td>
|
||||
<td class="int">{{ row['approval_count']|numberfmt }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
@ -39,7 +39,7 @@
|
|||
{% for row in reviews_monthly: %}
|
||||
<tr>
|
||||
<td>{{ row['user__display_name'] }}</td>
|
||||
<td class="int">{{ row['approval__count']|numberfmt }}</td>
|
||||
<td class="int">{{ row['approval_count']|numberfmt }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -23,7 +23,7 @@ from . test_models import create_addon_file
|
|||
|
||||
|
||||
class EditorTest(test_utils.TestCase):
|
||||
fixtures = ('base/users', 'editors/pending-queue')
|
||||
fixtures = ('base/users', 'editors/pending-queue', 'base/approvals')
|
||||
|
||||
def login_as_editor(self):
|
||||
assert self.client.login(username='editor@mozilla.com',
|
||||
|
@ -105,7 +105,7 @@ class TestReviewLog(EditorTest):
|
|||
eq_(r.status_code, 200)
|
||||
doc = pq(r.content)
|
||||
assert doc('.listing button'), 'No filters.'
|
||||
# shoul have 50 showing
|
||||
# Should have 50 showing.
|
||||
eq_(len(doc('tbody tr').not_('.hide')), 50)
|
||||
eq_(doc('tbody tr.hide').eq(0).text(), 'youwin')
|
||||
|
||||
|
@ -114,7 +114,7 @@ class TestReviewLog(EditorTest):
|
|||
Let's use today as an end-day filter and make sure we see stuff if we
|
||||
filter.
|
||||
"""
|
||||
# make sure we show th stuff we just made
|
||||
# Make sure we show the stuff we just made.
|
||||
date = time.strftime('%Y-%m-%d')
|
||||
r = self.client.get(reverse('editors.reviewlog') + '?end=' + date)
|
||||
eq_(r.status_code, 200)
|
||||
|
@ -127,7 +127,24 @@ class TestHome(EditorTest):
|
|||
"""Test the page at /editors."""
|
||||
def setUp(self):
|
||||
self.login_as_editor()
|
||||
amo.set_user(UserProfile.objects.get(username='editor'))
|
||||
self.user = UserProfile.objects.get(id=5497308)
|
||||
self.user.display_name = 'editor'
|
||||
self.user.save()
|
||||
amo.set_user(self.user)
|
||||
|
||||
def approve_reviews(self):
|
||||
Platform.objects.create(id=amo.PLATFORM_ALL.id)
|
||||
u = self.user
|
||||
|
||||
now = datetime.now()
|
||||
created = datetime(now.year - 1, now.month, 1)
|
||||
|
||||
for i in xrange(50):
|
||||
a = Addon.objects.create(type=amo.ADDON_EXTENSION)
|
||||
v = Version.objects.create(addon=a)
|
||||
f = File.objects.create(version=v)
|
||||
|
||||
Approval(addon=a, user=u, file=f, created=created).save(force_insert=True)
|
||||
|
||||
def test_approved_review(self):
|
||||
review = self.make_review()
|
||||
|
@ -145,6 +162,31 @@ class TestHome(EditorTest):
|
|||
eq_(doc('.row').eq(0).text().strip().split('.')[0],
|
||||
'editor deleted review %d' % review.id)
|
||||
|
||||
def test_stats_total(self):
|
||||
review = self.approve_reviews()
|
||||
|
||||
r = self.client.get(reverse('editors.home'))
|
||||
doc = pq(r.content)
|
||||
|
||||
display_name = doc('.editor-stats-table:eq(0)').find('td')[0].text
|
||||
eq_(display_name, self.user.display_name)
|
||||
|
||||
approval_count = doc('.editor-stats-table:eq(0)').find('td')[1].text
|
||||
# 50 generated + 1 fixture from a past month
|
||||
eq_(int(approval_count), 51)
|
||||
|
||||
def test_stats_monthly(self):
|
||||
review = self.approve_reviews()
|
||||
|
||||
r = self.client.get(reverse('editors.home'))
|
||||
doc = pq(r.content)
|
||||
|
||||
display_name = doc('.editor-stats-table:eq(1)').find('td')[0].text
|
||||
eq_(display_name, self.user.display_name)
|
||||
|
||||
approval_count = doc('.editor-stats-table:eq(1)').find('td')[1].text
|
||||
# 50 generated; doesn't show the fixture from a past month
|
||||
eq_(int(approval_count), 50)
|
||||
|
||||
class QueueTest(EditorTest):
|
||||
fixtures = ['base/users']
|
||||
|
|
|
@ -266,8 +266,8 @@ class Approval(amo.models.ModelBase):
|
|||
@staticmethod
|
||||
def total_reviews():
|
||||
return (Approval.objects.values('user', 'user__display_name')
|
||||
.annotate(models.Count('approval'))
|
||||
.order_by('-approval__count')[:5])
|
||||
.annotate(approval_count=models.Count('id'))
|
||||
.order_by('-approval_count')[:5])
|
||||
|
||||
@staticmethod
|
||||
def monthly_reviews():
|
||||
|
@ -275,8 +275,8 @@ class Approval(amo.models.ModelBase):
|
|||
created_date = datetime(now.year, now.month, 1)
|
||||
return (Approval.objects.values('user', 'user__display_name')
|
||||
.filter(created__gte=created_date)
|
||||
.annotate(models.Count('approval'))
|
||||
.order_by('-approval__count')[:5])
|
||||
.annotate(approval_count=models.Count('id'))
|
||||
.order_by('-approval_count')[:5])
|
||||
|
||||
|
||||
class Platform(amo.models.ModelBase):
|
||||
|
|
Загрузка…
Ссылка в новой задаче