Class: Marketing::CampaignInfluence::Result

Inherits:
Data
  • Object
show all
Defined in:
app/queries/marketing/campaign_influence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#distinct_influenced_invoicesObject (readonly)

Returns the value of attribute distinct_influenced_invoices

Returns:

  • (Object)

    the current value of distinct_influenced_invoices



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def distinct_influenced_invoices
  @distinct_influenced_invoices
end

#distinct_influenced_revenueObject (readonly)

Returns the value of attribute distinct_influenced_revenue

Returns:

  • (Object)

    the current value of distinct_influenced_revenue



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def distinct_influenced_revenue
  @distinct_influenced_revenue
end

#end_dateObject (readonly)

Returns the value of attribute end_date

Returns:

  • (Object)

    the current value of end_date



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def end_date
  @end_date
end

#period_invoicesObject (readonly)

Returns the value of attribute period_invoices

Returns:

  • (Object)

    the current value of period_invoices



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def period_invoices
  @period_invoices
end

#period_revenueObject (readonly)

Returns the value of attribute period_revenue

Returns:

  • (Object)

    the current value of period_revenue



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def period_revenue
  @period_revenue
end

#rowsArray<Row> (readonly)

Returns campaigns with at least one touched invoice,
richest influence first.

Returns:

  • (Array<Row>)

    campaigns with at least one touched invoice,
    richest influence first



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/queries/marketing/campaign_influence.rb', line 99

Result = Data.define(:rows, :start_date, :end_date, :window_days,
                     :period_invoices, :period_revenue,
                     :distinct_influenced_invoices, :distinct_influenced_revenue) do
  # Guards against a caller summing {Row#influenced_revenue} across rows.
  # One deal can appear under several campaigns at full value, which is the
  # point of an influence list and the reason it is not a revenue split.
  #
  # @return [Boolean]
  def revenue_is_summable? = false

  # Campaigns whose reach is too broad to rank on. Not a data problem —
  # a nurturing programme legitimately touches most customers — but their
  # influence total says more about the programme's size than about any
  # deal, so they belong in their own bucket rather than at the top of a
  # league table.
  #
  # @return [Array<Row>]
  def always_on = rows.select(&:always_on?)

  # @return [Array<Row>] the rows worth ranking against each other
  def discriminating = rows.reject(&:always_on?)
end

#start_dateObject (readonly)

Returns the value of attribute start_date

Returns:

  • (Object)

    the current value of start_date



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def start_date
  @start_date
end

#window_daysObject (readonly)

Returns the value of attribute window_days

Returns:

  • (Object)

    the current value of window_days



99
100
101
# File 'app/queries/marketing/campaign_influence.rb', line 99

def window_days
  @window_days
end

Instance Method Details

#always_onArray<Row>

Campaigns whose reach is too broad to rank on. Not a data problem —
a nurturing programme legitimately touches most customers — but their
influence total says more about the programme's size than about any
deal, so they belong in their own bucket rather than at the top of a
league table.

Returns:



116
# File 'app/queries/marketing/campaign_influence.rb', line 116

def always_on = rows.select(&:always_on?)

#discriminatingArray<Row>

Returns the rows worth ranking against each other.

Returns:

  • (Array<Row>)

    the rows worth ranking against each other



119
# File 'app/queries/marketing/campaign_influence.rb', line 119

def discriminating = rows.reject(&:always_on?)

#revenue_is_summable?Boolean

Guards against a caller summing Marketing::CampaignInfluence::Row#influenced_revenue across rows.
One deal can appear under several campaigns at full value, which is the
point of an influence list and the reason it is not a revenue split.

Returns:

  • (Boolean)


107
# File 'app/queries/marketing/campaign_influence.rb', line 107

def revenue_is_summable? = false