Skip to content
Snippets Groups Projects
Commit dfef8a45 authored by Eike Cochu's avatar Eike Cochu
Browse files

added gzip to rest service

all rest responses are now gzipped by default if supported
parent d199e37a
Branches
No related tags found
No related merge requests found
package de.vipra.rest; package de.vipra.rest;
import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.message.GZipEncoder;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.filter.EncodingFilter;
import de.vipra.rest.provider.APIRequestFilter; import de.vipra.rest.provider.APIRequestFilter;
import de.vipra.rest.provider.CORSResponseFilter; import de.vipra.rest.provider.CORSResponseFilter;
...@@ -17,6 +19,7 @@ public class Application extends ResourceConfig { ...@@ -17,6 +19,7 @@ public class Application extends ResourceConfig {
register(ObjectMapperProvider.class); register(ObjectMapperProvider.class);
register(APIRequestFilter.class); register(APIRequestFilter.class);
register(PatchReaderInterceptor.class); register(PatchReaderInterceptor.class);
EncodingFilter.enableFor(this, GZipEncoder.class);
} }
} }
import Ember from 'ember'; import Ember from 'ember';
var statsData = [];
var statsOptions = {
title: {
text: 'Word frequencies'
},
legend: {
enabled: false
},
xAxis: {
title: {
text: 'Words'
}
},
yAxis: {
title: {
text: 'Count'
}
},
tooltip: {
headerFormat: '',
pointFormat: '{point.x}: {point.y} time(s)'
}
};
export default Ember.Route.extend({ export default Ember.Route.extend({
model(params) { model(params) {
return Ember.RSVP.hash({ return Ember.RSVP.hash({
article: this.store.find('article', params.article_id), article: this.store.find('article', params.article_id),
statsData: statsData, statsData: []
statsOptions: statsOptions
}); });
}, },
afterModel(model) { afterModel(model) {
if(model.article.stats) { var words = [],
stats = model.article.get('stats');
for(var word in stats.uniqueWords) {
var o = stats.uniqueWords[word];
words.push({word: word, count: o.termFrequency, norm: o.normalizedTermFrequency});
} }
words.sort(function(a,b) {
return b.count - a.count;
});
model.statsData = words.slice(0,20);
} }
}); });
\ No newline at end of file
td {
vertical-align: top;
}
\ No newline at end of file
...@@ -12,18 +12,41 @@ ...@@ -12,18 +12,41 @@
<h3>Statistics</h3> <h3>Statistics</h3>
<table> <table>
<tr> <tbody>
<td>Word count</td> <tr>
<td>{{model.article.stats.wordCount}}</td> <td>Word count</td>
</tr> <td>{{model.article.stats.wordCount}}</td>
<tr> </tr>
<td>Unique word count</td> <tr>
<td>{{model.article.stats.uniqueWordCount}}</td> <td>Unique word count</td>
</tr> <td>{{model.article.stats.uniqueWordCount}}</td>
</tr>
<tr>
<td>Most frequent words</td>
<td>
<table>
<thead>
<tr>
<th>Word</th>
<th>Count</th>
<th>NTF</th>
</tr>
</thead>
<tbody>
{{#each model.statsData as |stats|}}
<tr>
<td>{{stats.word}}</td>
<td>{{stats.count}}</td>
<td>{{stats.norm}}</td>
</tr>
{{/each}}
</tbody>
</table>
</td>
</tr>
</tbody>
</table> </table>
{{dynamic-high-charts content=model.statsData chartOptions=model.statsOptions}}
<h3>Content</h3> <h3>Content</h3>
{{model.article.text}} {{model.article.text}}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment