Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
babysteps progress
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Oct 16, 2013
1 parent 5f78a11 commit 4fc0f10
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
8 changes: 8 additions & 0 deletions apps/shipping/forms.py
Expand Up @@ -30,3 +30,11 @@ class SignoffFilterForm(forms.Form):
ms = ModelInstanceField(Milestone, key='code', required=False)
av = ModelInstanceField(AppVersion, key='code', required=False)
up_until = forms.fields.DateTimeField(required=False)


class SignoffsPaginationForm(forms.Form):
push_date = forms.DateTimeField(
input_formats=forms.DateTimeField.input_formats + (
'%Y-%m-%dT%H:%M:%S', # isoformat
)
)
20 changes: 20 additions & 0 deletions apps/shipping/static/shipping/js/signoffs.js
Expand Up @@ -117,6 +117,26 @@ $(document).ready(function() {
rs.dialog('open');
});
}

$('a.load-more').click(function() {
var this_row = $(this).parents('tr');
var min_push_date;
$('tr.pushrow').each(function(i, each) {
if ($(each).data('push_date')) {
min_push_date = $(each).data('push_date');
}
});
var url = location.pathname;
//console.log('URL', url);
console.log('min_push_date', min_push_date);
console.log('# rows before', $('tr.pushrow').length);
var req = $.get(url + '/more/', {push_date: min_push_date});
req.then(function(html) {
$(html).insertBefore(this_row);
console.log('# rows after', $('tr.pushrow').length);
});
return false;
});
});

var Review = {
Expand Down
4 changes: 2 additions & 2 deletions apps/shipping/templates/shipping/signoff-rows.html
Expand Up @@ -11,7 +11,7 @@
{% else %}
<tr class="push-spacer"></tr>
{% endif %}
<tr class="pushrow {% if forloop.first %}pushrow-first{% endif %}" id="{{push.id}}" data-push="{{push.push_id}}">
<tr class="pushrow {% if forloop.first %}pushrow-first{% endif %}" id="{{push.id}}" data-push="{{push.push_id}}" data-push_date="{{push.push_date.isoformat}}">
<td class="push{% if forloop.first %} top{% endif %}{% if forloop.last %} bottom {% endif %}" rowspan="{{push.rows}}">{{push.when|date}}<br><span class="csuser">{{push.who}}</span></td>
<td rowspan="{{push.changerows}}">{{push.run|showrun}}<br>
<span class="csuser">{{push.run.build.starttime|date}}</span></td>
Expand All @@ -37,7 +37,7 @@
</td>
<td class="diff {% if forloop.first %}diff-first{% endif %}">{% for _i in cs.diffbases %}<div class="diffanchor"></div>{% endfor %}</td></tr>
{% if not forloop.last %}
<tr class="pushrow pushrow-inner" data-push="{{push.push_id}}">
<tr class="pushrow pushrow-inner" data-push="{{push.push_id}}" data-push_date="{{push.push_date.isoformat}}">
{% endif %}
{% endfor %}
{% if push.signoffs|length %}
Expand Down
7 changes: 5 additions & 2 deletions apps/shipping/templates/shipping/signoffs.html
Expand Up @@ -117,8 +117,11 @@ <h1>Sign-offs for {{appver}} in {{language}}</h1>
{% endif %}
<table id="pushtable" class="standard">
{% include "shipping/signoff-rows.html" %}
<tr><td colspan="4" class="note">Loading more data will be part of
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=658656">bug 658656</a></td></tr>
<tr>
<td colspan="4" class="note">
<a href="#" class="load-more">Load more</a>
</td>
</tr>
{% if fallback %}
<tr class="tree-change-spacer"></tr>
<tr class="pushrow" id="{{fallback.tip.shortrev}}" data-push="{{fallback.tip.shortrev}}">
Expand Down
1 change: 1 addition & 0 deletions apps/shipping/urls.py
Expand Up @@ -41,6 +41,7 @@
)

urlpatterns += patterns('shipping.views.signoff',
(r'^/signoffs/(.*)/(.*)/more/$', 'signoff_rows'),
(r'^/signoffs/(.*)/$', 'signoff_locale'),
(r'^/signoffs/(.*?)/(.*)', 'signoff'),
(r'^/signoffs-details/(.*?)/(.*)', 'signoff_details'),
Expand Down
40 changes: 38 additions & 2 deletions apps/shipping/views/signoff.py
Expand Up @@ -21,6 +21,7 @@
from l10nstats.models import Run_Revisions, Run
from shipping.models import AppVersion, Signoff, Action
from shipping.api import flags4appversions
from shipping.forms import SignoffsPaginationForm


def signoff_locale(request, locale_code):
Expand All @@ -38,6 +39,10 @@ class SignoffView(TemplateView):
"""
template_name = 'shipping/signoffs.html'

count = 10
offset = 0
min_push_date = None

def get(self, request, locale_code, app_code):
appver = get_object_or_404(AppVersion, code=app_code)
lang = get_object_or_404(Locale, code=locale_code)
Expand Down Expand Up @@ -73,6 +78,9 @@ def get_context_data(self, lang, appver):
fallback,
lang,
appver,
min_push_date=self.min_push_date,
count=self.count,
offset=self.offset
)

try:
Expand All @@ -97,10 +105,14 @@ def get_context_data(self, lang, appver):
}

def annotated_pushes(self, actions, flags, fallback,
lang, appver, count=10):
lang, appver,
min_push_date=None,
count=10, offset=0):
pushes_q = (Push.objects
.filter(changesets__branch__id=1)
.order_by('-push_date'))
if min_push_date:
pushes_q = pushes_q.filter(push_date__lt=min_push_date)
# Find the repos via trees_over_time
forest4times = dict()
tree4forest = dict()
Expand Down Expand Up @@ -158,6 +170,7 @@ def annotated_pushes(self, actions, flags, fallback,
if len(initial_diff) < 2:
initial_diff.append(a.signoff_id)

last_push_date = None
if cutoff_dates:
last_push_date = min(cutoff_dates)
if fallback or Action.ACCEPTED not in flags:
Expand All @@ -178,7 +191,12 @@ def annotated_pushes(self, actions, flags, fallback,
.distinct()
)
else:
pushes_q = pushes_q.distinct()[:count]
#if pushes_q.distinct().count() > count:
# raise Exception(lang)
print( pushes_q.distinct().count() , count)
pushes_q = pushes_q.distinct()[offset:count]

print ('last_push_date', last_push_date)

# get pushes, changesets and signoffs/actions
_p = list(pushes_q.values_list('id', flat=True))
Expand Down Expand Up @@ -297,6 +315,7 @@ def wrapup(self, push=None, cs=None):
if push is not None:
self.pushes.append({'changes': [],
'push_id': push.id,
'push_date': push.push_date,
'who': push.user,
'when': push.push_date,
'repo': push.repository.name,
Expand All @@ -309,6 +328,23 @@ def wrapup(self, push=None, cs=None):
signoff = SignoffView.as_view()


class SignoffRowsView(SignoffView):

template_name = 'shipping/signoff-rows.html'

def get(self, request, *args, **kwargs):

self.offset = int(request.GET.get('offset', 0))
form = SignoffsPaginationForm(request.GET)
if form.is_valid():
self.min_push_date = form.cleaned_data['push_date']
else:
raise NotImplementedError(form.errors)
return super(SignoffRowsView, self).get(request, *args, **kwargs)


signoff_rows = SignoffRowsView.as_view()

def signoff_details(request, locale_code, app_code):
"""Details pane loaded on sign-off on a particular revision.
Expand Down

0 comments on commit 4fc0f10

Please sign in to comment.