Skip to content

Commit

Permalink
improve number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsteward committed Aug 3, 2020
1 parent 5bc50a5 commit e4e6119
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ router.get('/', function(req, res, next) {
data.dateoflastrefresh = results['objectStats']['lastrefresh'];
data.dateoflastexport = results['objectStats']['lastexport'];
data.objects.count = results['objectStats']['recordcount'];
data.objects.count_as_string = data.objects.count.toLocaleString('en');
data.objects.public.count = results['objectStats']['recordcount_public'];
data.objects.public.count_as_string = data.objects.public.count.toLocaleString('en');
data.objects.public.count_as_percent = ((results['objectStats']['recordcount_public']/results['objectStats']['recordcount'])*100).toFixed(2);
data.objects.onview.count = results['objectsOnViewStats'];
data.objects.onview.count_as_string = data.objects.onview.count.toLocaleString('en');
data.objects.onview.count_as_percent = ((results['objectsOnViewStats']/results['objectStats']['recordcount'])*100).toFixed(2);
data.exhibitions.current = results['currentExhibitions'];
data.objects.alttext.count = results['alttextStats'];
data.objects.alttext.count_as_percent = ((data.objects.alttext.count/data.objects.count)*100).toFixed(2);
data.pageviews = results['activityStats']['pageviews'];
data.pageviews.objects.count_as_string = data.pageviews.objects.count.toLocaleString('en');
data.pageviews.objects.count_as_percent = ((data.pageviews.objects.count/data.objects.public.count)*100).toFixed(2)

// calculate the age of the data
Expand Down
8 changes: 4 additions & 4 deletions views/production.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<p class="lead">{{apistats.objects.onview.count_as_percent}}% of the collection is on view in galleries.</p>

<ul class="list-group">
<li class="list-group-item"># of objects: {{apistats.objects.count}}</li>
<li class="list-group-item"># of objects online: {{apistats.objects.public.count}} </li>
<li class="list-group-item"># of objects installed: {{apistats.objects.onview.count}} </li>
<li class="list-group-item"># of active objects in TMS: {{apistats.objects.count_as_string}}</li>
<li class="list-group-item"># of objects online: {{apistats.objects.public.count_as_string}} </li>
<li class="list-group-item"># of objects installed: {{apistats.objects.onview.count_as_string}} </li>
</ul>
</div>
</div>
Expand All @@ -44,7 +44,7 @@
<div class="card-body">
<h2 class="card-title">Website Statistics*</h2>

<p class="lead">{{apistats.pageviews.objects.count}} individual objects have been viewed on our website to date. That's {{apistats.pageviews.objects.count_as_percent}}% of the collection.</p>
<p class="lead">{{apistats.pageviews.objects.count_as_string}} individual objects have been viewed on our website to date. That's {{apistats.pageviews.objects.count_as_percent}}% of the collection.</p>

<p>The object with the most views in a single day: </p>
<img class="img-fluid" src="{{apistats.pageviews.singledaymostviews.object.images.[0].iiifbaseuri}}/full/!400,400/0/default.jpg">
Expand Down

0 comments on commit e4e6119

Please sign in to comment.