Permalink
Browse files

fixed the facet filtering - not using the app_id match for now

  • Loading branch information...
1 parent f7a57a5 commit 5994f1c6370a92b25678c3d475db236717f4f1e9 @tarekziade tarekziade committed Feb 20, 2013
Showing with 36 additions and 19 deletions.
  1. +2 −2 monolith/media/app.js
  2. +15 −8 monolith/media/index.html
  3. +17 −8 monolith/media/lib/monolith.js
  4. +2 −1 monolith/views.py
View
@@ -78,9 +78,9 @@ app.directive('chart', function() {
'<div class="modal-body">' +
'<form id="query-{{id}}"><fieldset>' +
'<label for="startdate-{{id}}">Start Date</label>' +
- '<input type="text" id="startdate-{{id}}" value="01/01/2012"/>' +
+ '<input type="text" id="startdate-{{id}}" value="01/13/2013"/>' +
'<label for="enddate-{{id}}"> End date </label>' +
- '<input type="text" id="enddate-{{id}}" value="03/01/2012"/>' +
+ '<input type="text" id="enddate-{{id}}" value="03/01/2013"/>' +
'<label for="appid-{{id}}"> App id (1 to 100)</label>' +
'<input type="text" id="appid-{{id}}" value="1"/>' +
'<br/>' + // err well
View
@@ -39,21 +39,25 @@
</div> <!-- end navbar-->
-<dashboard server="http://0.0.0.0:6543">
+<dashboard server="http://166.78.8.5:6543">
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
+ <div class="span6">
+ <chart title="Daily Page views"
+ id="chart2"
+ type="aggregate"
+ field="pageviews"
+ interval="day"/>
+ </div>
+
<div class="span6">
+<!--
<chart title="Downloads and Daily Users"
id="chart1"
fields="downloads_count,users_count"
type="series"/>
- </div>
- <div class="span6">
- <chart title="Daily Users"
- id="chart2"
- fields="users_count"
- type="series"/>
+-->
</div>
</div> <!-- end of span12 -->
</div> <!-- end of row-fluid -->
@@ -62,18 +66,21 @@
<div class="span12">
<div class="span6">
+<!--
<chart title="Downloads"
id="chart3"
fields="downloads_count"
type="series"/>
+-->
</div>
<div class="span6">
+<!--
<chart title="Download counts per month"
id="chart4"
type="aggregate"
field="downloads_count"
interval="month"/>
-
+ -->
</div>
</div> <!-- end of span12 -->
@@ -103,8 +103,8 @@ $.Class.extend("MonolithBase", {},
// picking the dates
var start_date = $(this.start_date).data('datepicker').date;
var end_date = $(this.end_date).data('datepicker').date;
- var start_date_str = start_date.toISOString();
- var end_date_str = end_date.toISOString();
+ var start_date_str = start_date.toISOString().split("T")[0];
+ var end_date_str = end_date.toISOString().split("T")[0];
this._drawRange($(this.appid).val(), start_date, end_date,
start_date_str, end_date_str);
},
@@ -299,17 +299,26 @@ MonolithBase.extend("MonolithAggregate",
delta = Math.round(delta / one_day);
this.chart.showLoading();
var i, x, y;
- var query = {"query": {"field": {"add_on": app_id}},
+ //var match = {"field": {"add_on": app_id}};
+ var match = {'match_all': {}};
+
+ var query = {"query": match,
"facets": {
- "facet_histo" : {"date_histogram" : {"key_field" : "date",
- "value_field": this.field,
- "interval": this.interval}}
+ "facet_histo" : {"date_histogram" : {
+ "key_field" : "date",
+ "value_field": this.field,
+ "interval": this.interval},
+ "facet_filter": {
+ "range":
+ {"date": {"gte": start_date_str,
+ "lt": end_date_str}
+ }
+ }
+ }
},
- "filter": {"range": {"date": {"gte": start_date_str, "lt": end_date_str}}},
"sort": [{"date": {"order" : "asc"}}],
"size": delta
};
-
query = JSON.stringify(query);
this._async(query);
this.chart.hideLoading();
View
@@ -20,7 +20,8 @@ class ElasticSearchQuery(MappingSchema):
def get_info(request):
"""Returns info on the Monolith server, like the list of queriable fields
"""
- return {'fields': ['downloads_count', 'users_count'],
+ # XXX config ?
+ return {'fields': ['downloads_count', 'users_count', 'pageviews'],
'es_endpoint': '/v1/time'}

0 comments on commit 5994f1c

Please sign in to comment.