Proca.Server.Stats (proca v3.4.1)

Stores campaign and action page signature counts in following structure (under campaign state key):

  • map of campaign ids stores a following structure:
    • supporters - how many deduplicated supporters in total (including extra_supporters)
    • action - action counts grouped by action type
    • area - supporters grouped by area
    • org - supporters grouped by org name

extra_supporters are not included in action counts, nor in area counts (we do not know where they belong).

Process state structure:

  • interval: int - calculation interval in ms
  • query_runs: boolean - a flag saying calculation is running now and we shouldn't run new calculation
  • campaign: campaign_id -> %Stats{} (map)

Link to this section Summary

Functions

Run the full calculation of stats

Returns a specification to start this module under a supervisor.

  • Get stats for campaign
  • Get stats for action types

Every @sync_every_ms ms we send to ourselves a :sync message, to synchronize counts from DB.

Increment by one action count for particular action_type collected by org with org_id, in campaign with campaign_id. The new_supporter is true if addActionContact was used to create action + supporter, otherwise a supporter was re-used (addAction).

Get stats for this campaign_id from Stat process.

Link to this section Functions

Run the full calculation of stats

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

handle_call(msg, arg2, state)

  • Get stats for campaign
  • Get stats for action types
Link to this function

handle_info(msg, state)

Every @sync_every_ms ms we send to ourselves a :sync message, to synchronize counts from DB.

Link to this function

increment(campaign_id, org_id, action_type, new_supporter)

Increment by one action count for particular action_type collected by org with org_id, in campaign with campaign_id. The new_supporter is true if addActionContact was used to create action + supporter, otherwise a supporter was re-used (addAction).

Link to this function

increment(campaign_id, org_id, action_type, area, new_supporter)

Same as increment/4 but provides area

Link to this function

start_link(args)

Link to this function

stats(campaign_id)

Get stats for this campaign_id from Stat process.