Added clicks stats to links table

This commit is contained in:
Andris Reinman 2016-05-05 14:57:56 +03:00
parent 09de6e4576
commit 3273c43184
2 changed files with 21 additions and 3 deletions

View file

@ -278,6 +278,12 @@ router.get('/view/:id', passport.csrfProtection, (req, res) => {
let index = 0;
campaign.links = (links || []).map(link => {
link.index = ++index;
link.totalPercentage = campaign.delivered ? Math.round(((link.clicks / campaign.delivered) * 100) * 1000) / 1000 : 0;
link.relPercentage = campaign.clicks ? Math.round(((link.clicks / campaign.clicks) * 100) * 1000) / 1000 : 0;
link.short = link.url.replace(/^https?:\/\/(www.)?/i, '');
if (link.short > 63) {
link.short = link.short.substr(0, 60) + '…';
}
return link;
});
campaign.showOverview = true;

View file

@ -273,9 +273,15 @@
<th>
URL
</th>
<th class="col-md-2">
<th class="col-md-1">
Clicked
</th>
<th class="col-md-1">
% of clicks
</th>
<th class="col-md-1">
% of messages
</th>
</thead>
<tbody>
{{#if links}}
@ -285,16 +291,22 @@
{{index}}
</td>
<td>
<a href="{{url}}">{{url}}</a>
<a href="{{url}}">{{short}}</a>
</td>
<td>
{{clicks}}
</td>
<td>
{{relPercentage}}
</td>
<td>
{{totalPercentage}}
</td>
</tr>
{{/each}}
{{else}}
<tr>
<td colspan="3">
<td colspan="5">
No data available in table
</td>
</tr>