Permalink
Browse files

integrate with socorro style, handle edge cases in the data, fix tests

  • Loading branch information...
1 parent 839d90c commit a7b0cb4fef595c506e16ebb6c2fc634347d59b0a @lonnen lonnen committed Mar 21, 2013
@@ -648,7 +648,7 @@ def get(self, duration=12, decode_json=True):
class CrontabberState(SocorroMiddleware):
- # commented out temporarily whilst hacking cache_seconds = 60 * 5 # 5 minutes
+ cache_seconds = 60 * 5 # 5 minutes
def get(self):
return self.fetch('/crontabber_state/')
@@ -21,3 +21,7 @@
thead td {
font-weight: bold;
}
+
+.tablesorter .header {
+ padding: 0.5em;
+}
@@ -98,7 +98,8 @@ d3.sankey = function() {
nodes.forEach(function(node) {
node.value = Math.max(
d3.sum(node.sourceLinks, value),
- d3.sum(node.targetLinks, value)
+ d3.sum(node.targetLinks, value),
+ 1 // base value
);
});
}
@@ -176,10 +176,15 @@ d3.json("data.json", function(data) {
'depends_on'
];
+ table.classed('tablesorter', true)
+
thead.append("tr").selectAll("td")
.data(tableFields)
.enter().append("td")
- .text(_.identity);
+ .text(function capitalize(s) {
+ return s[0].toUpperCase() + s.slice(1);
+ })
+ .classed("header", true);
var tr = tbody.selectAll("tr")
.data(nodes)
@@ -207,4 +212,6 @@ d3.json("data.json", function(data) {
}
return d;
});
+
+ $('crontabber-table tablesorter').tablesorter();
});
@@ -7,6 +7,8 @@
{% block site_css %}
{{ super() }}
{% compress css %}
+ <link media="screen" href="{{ static('crashstats/css/flora/flora.css') }}" type="text/css" rel="stylesheet">
+ <link media="screen" href="{{ static('crashstats/css/flora/flora.tablesorter.css') }}" type="text/css" rel="stylesheet">
<link media="screen" href="{{ static('crashstats/css/crontabber_state.css') }}" type="text/css" rel="stylesheet">
{% endcompress %}
{% endblock %}
@@ -15,6 +17,7 @@
{% block site_js %}
{{ super() }}
{% compress js %}
+ <script src="{{ static('crashstats/js/jquery/plugins/ui/jquery.tablesorter.min.js') }}"></script>
<script src="{{ static('crashstats/js/moment.min.js') }}"></script>
<script src="{{ static('crashstats/js/underscore-min.js') }}"></script>
<script src="{{ static('crashstats/js/d3.min.js') }}"></script>
@@ -1749,18 +1749,8 @@ def mocked_get(**options):
response = self.client.get(url)
eq_(response.status_code, 200)
- ok_('slow-zero' in response.content)
- ok_('slow-one' in response.content)
- ok_('slow-two' in response.content)
- # because you're not logged in
- ok_('error error error' not in response.content)
-
- User.objects.create_user('test', 'test@mozilla.com', 'secret')
- assert self.client.login(username='test', password='secret')
- response = self.client.get(url)
- eq_(response.status_code, 200)
- # now you're allowed to see it
- ok_('error error error' in response.content)
+ ok_('2000-01-01T00:00:00+00:00' in response.content)
+ ok_('1/01/2000 00:00 UTC' in response.content)
@mock.patch('requests.post')
@mock.patch('requests.get')
@@ -1128,40 +1128,16 @@ def status_json(request):
@set_base_data
def crontabber_state(request):
response = models.CrontabberState().get()
- #state = response['state']
- print "RESPONSE"
- from pprint import pprint
- pprint(response)
last_updated = response['last_updated']
- def parse(date_str, format='%Y-%m-%d %H:%M:%S.%f'):
- return datetime.datetime.strptime(date_str, format)
-
- def parse_all_dates(struct):
- for key, value in struct.items():
- if isinstance(value, basestring):
- try:
- struct[key] = parse(value)
- except ValueError:
- pass
- elif isinstance(value, dict):
- parse_all_dates(value)
- #parse_all_dates(state)
last_updated = (
isodate.parse_datetime(last_updated)
.replace(tzinfo=utc)
)
data = {
- 'last_updated': last_updated,
- #'state': state,
+ 'last_updated': last_updated
}
return render(request, 'crashstats/crontabber_state.html', data)
- return data
-
-
-def crontabber_state_html(request):
- data = crontabber_state(request)
- return render(request, 'crashstats/crontabber_state.html', data)
@utils.json_view

0 comments on commit a7b0cb4

Please sign in to comment.