Skip to content

Commit

Permalink
Unification of minVisit parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Apr 5, 2017
1 parent 9cc174c commit 0c77e73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ In order to calculate the score,
options can be provided when creating the object.
The defaults are:

{ minDuration : 10 * 1000
{ minPublisherDuration : 8 * 1000
, numFrames : 30
, frameSize : 24 * 60 * 60 * 1000
}

When `addVisit` is invoked,
the duration must be at least `minDuration` milliseconds in length.
the duration must be at least `minPublisherDuration` milliseconds in length.
If so,
then one or more "scorekeepers" are run to calculate the score for the visit,
using both the `options` and `props`.
Expand Down Expand Up @@ -198,8 +198,8 @@ only the `concave` scorekeeper makes use of these.
The defaults are:

{ _d : 1 / (30 * 1000) // 0.0000333...
, _a : (1 / (_d * 2)) - minDuration // 5000
, _b : minDuration - _a // 5000
, _a : (1 / (_d * 2)) - minPublisherDuration // 5000
, _b : minPublisherDuration - _a // 5000
}

The sliding window consist of `numFrames` frames,
Expand Down
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ var Synopsis = function (options) {

this.options = options || {}
this.options.scorekeepers = underscore.keys(Synopsis.prototype.scorekeepers)
underscore.defaults(this.options, { minDuration: 10 * 1000,
underscore.defaults(this.options, { minPublisherDuration: 8 * 1000,
numFrames: 30,
frameSize: 24 * 60 * 60 * 1000,
_d: 1 / (30 * 1000),
minPublisherDuration: 0,
minPublisherVisits: 0
})
if (!this.options.scorekeepers[this.options.scorekeeper]) {
Expand All @@ -128,10 +127,10 @@ var Synopsis = function (options) {
this.options.emptyScores[scorekeeper] = 0
}, this)

underscore.defaults(this.options, { _a: (1 / (this.options._d * 2)) - this.options.minDuration })
underscore.defaults(this.options, { _a: (1 / (this.options._d * 2)) - this.options.minPublisherDuration })
this.options._a2 = this.options._a * 2
this.options._a4 = this.options._a2 * 2
underscore.defaults(this.options, { _b: this.options.minDuration - this.options._a })
underscore.defaults(this.options, { _b: this.options.minPublisherDuration - this.options._a })
this.options._b2 = this.options._b * this.options._b

underscore.keys(this.publishers).forEach(function (publisher) {
Expand Down Expand Up @@ -164,7 +163,7 @@ var Synopsis = function (options) {
Synopsis.prototype.addVisit = function (location, duration, markup) {
var publisher

if (duration < this.options.minDuration) return
if (duration < this.options.minPublisherDuration) return

try { publisher = getPublisher(location, markup) } catch (ex) { return }
if (!publisher) return
Expand Down Expand Up @@ -205,7 +204,7 @@ Synopsis.prototype.addPublisher = function (publisher, props) {
if (!props) return

if (typeof props === 'number') props = { duration: props }
if ((!props.stickyP) && (props.duration < this.options.minDuration)) return
if ((!props.stickyP) && (props.duration < this.options.minPublisherDuration)) return

scores = this.scores(props)
if (!scores) return
Expand Down

0 comments on commit 0c77e73

Please sign in to comment.