View Source Squeeze.ActivityMatcher (OpenPace v0.0.1)

This module matches new activities to existing activities.

Link to this section Summary

Functions

Gets the closest activity for a user given an activity.

Link to this section Functions

Link to this function

get_closest_activity(user, activity)

View Source

Gets the closest activity for a user given an activity.

Matches on the following criteria:

  1. Only matches if the activities are on the same date
  2. Only matches if activities are of the same type (example: "Run" or "Ride")
  3. If multiple activities match, it scores the activities based on distance, duration, and external_id

Returns nil if no activities match

examples

Examples

iex> get_closest_activity(user, matching_activity) %Activity{}

iex> get_closest_activity(user, no_match_activity) null