always show at least 1 visitor if there are pageviews. #129

This commit is contained in:
Danny van Kooten 2018-09-19 08:21:04 +02:00
parent 0f08d8ed1d
commit 2ff9676043
2 changed files with 9 additions and 2 deletions

View File

@ -36,6 +36,11 @@ class Sidebar extends Component {
return;
}
// Make sure we always show at least 1 visitor when there are pageviews
if ( data.Visitors == 0 && data.Pageviews > 0 ) {
data.Visitors = 1
}
this.setState({
loading: false,
data: data
@ -47,7 +52,7 @@ class Sidebar extends Component {
return (
<div class="box box-totals animated fadeInUp delayed_03s">
<CountWidget title="Unique visitors" value={state.data.Visitors} loading={state.loading} />
<CountWidget title="Page views" value={state.data.Pageviews} loading={state.loading} />
<CountWidget title="Pageviews" value={state.data.Pageviews} loading={state.loading} />
<CountWidget title="Avg time on site" value={state.data.AvgDuration} format="duration" loading={state.loading} />
<CountWidget title="Bounce rate" value={state.data.BounceRate} format="percentage" loading={state.loading} />
</div>

View File

@ -2,8 +2,9 @@ package sqlstore
import (
"database/sql"
"github.com/usefathom/fathom/pkg/models"
"time"
"github.com/usefathom/fathom/pkg/models"
)
func (db *sqlstore) GetSiteStats(date time.Time) (*models.SiteStats, error) {
@ -49,6 +50,7 @@ func (db *sqlstore) GetAggregatedSiteStats(startDate time.Time, endDate time.Tim
if err != nil && err == sql.ErrNoRows {
return nil, ErrNoResults
}
return stats, err
}