Esempio n. 1
0
 /**
  * Tasks after insertion
  */
 protected function after()
 {
     parent::after();
     if (Cache::is('swimdata' . $this->NewObject->activityID())) {
         Cache::delete('swimdata' . $this->NewObject->activityID());
     }
 }
 /**
  * Construct collector
  * @param \Runalyze\Model\Trackdata\Entity $trackdata
  * @param int $key
  * @param \Runalyze\Model\Swimdata\Entity $swimdata
  * @throws \InvalidArgumentException
  */
 public function __construct(Trackdata $trackdata, $key, Swimdata $swimdata)
 {
     if (!$swimdata->has($key)) {
         throw new \InvalidArgumentException('Swimdata has no data for "' . $key . '".');
     }
     $this->Key = $key;
     $this->Precision = Configuration::ActivityView()->plotPrecision();
     $this->KnowsDistance = $trackdata->has(Trackdata::DISTANCE);
     $this->init($trackdata);
     $this->LoopSwimdata = new Loop($swimdata);
     $this->collect();
 }
Esempio n. 3
0
 /**
  * Construct context
  * @var int $activityID
  * @var int $accountID
  */
 public function __construct($activityID, $accountID)
 {
     $Factory = new Factory((int) $accountID);
     $this->Activity = $Factory->activity((int) $activityID);
     $this->Trackdata = $Factory->trackdata((int) $activityID);
     $this->Swimdata = $Factory->swimdata((int) $activityID);
     $this->Route = $this->Activity->get(Activity\Entity::ROUTEID) ? $Factory->route($this->Activity->get(Activity\Entity::ROUTEID)) : null;
     $this->HRV = $Factory->hrv((int) $activityID);
     $this->Sport = $Factory->sport($this->Activity->sportid());
     $this->Swimdata->fillDistanceArray($this->Trackdata);
     $this->Swimdata->fillSwolfArray($this->Trackdata);
     $this->Dataview = new Dataview($this->Activity);
 }
Esempio n. 4
0
 /**
  * Calculate swim values
  */
 protected function calculateSwimValues()
 {
     if (null !== $this->Trackdata && null !== $this->Swimdata) {
         if ($this->Swimdata->stroke()) {
             $this->Object->set(Entity::TOTAL_STROKES, array_sum($this->Swimdata->stroke()));
         }
         if ($this->Object->totalStrokes() && $this->Trackdata->totalTime()) {
             $num = $this->Trackdata->num();
             $totaltime = $this->Trackdata->totalTime();
             $totalstrokes = $this->Object->totalStrokes();
             if (!empty($totalstrokes) && !empty($totaltime) & !empty($num) && $totalstrokes != 0) {
                 $this->Object->set(Entity::SWOLF, round(($totalstrokes + $totaltime) / $num));
             }
         }
     }
 }
Esempio n. 5
0
 /**
  * Keys to update
  * @return array
  */
 protected function keys()
 {
     return array_merge(array(self::ACCOUNTID), array_diff(Entity::allProperties(), array(Entity::SWOLF, Entity::SWOLFCYCLES)));
 }