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; let index = 0;
campaign.links = (links || []).map(link => { campaign.links = (links || []).map(link => {
link.index = ++index; 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; return link;
}); });
campaign.showOverview = true; campaign.showOverview = true;

View file

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