private void CalculateActivity(Activity fvActivity) { ActivityStreams stream = ActivityStreams.CreateFromExistingActivityStream(fvActivity.Id); // stream must have watts to calculate TSS/IF! if (!stream.HasIndividualStream(enums.StreamType.Watts)) { return; } ZoneValueOnDay value = new ZoneValueOnDay(); var ftp = value.GetUserZoneValueOnGivenDate(fvActivity.Athlete.UserId, enums.ZoneType.BikePower, fvActivity.Start); if (ftp == null) { return; } BikePower calc = new BikePower(stream.GetIndividualStream <int?>(enums.StreamType.Watts), ftp.Value); fvActivity.TSS = calc.TSS(); fvActivity.IntensityFactor = calc.IntensityFactor(); _uow.Complete(); }
private void UpdateActivityDetails() { // update details missing from summary activity. _fvActivity.Calories = Convert.ToDecimal(_stravaActivity.Calories); _fvActivity.Description = _stravaActivity.Description; // gear?? _fvActivity.EmbedToken = _stravaActivity.EmbedToken; _fvActivity.DeviceName = _stravaActivity.DeviceName; _fvActivity.MapPolyline = _stravaActivity.Map.Polyline; // splits_metric // splits_standard if ((_fvActivity.HasPowerMeter) && (_convertedStream.HasIndividualStream(StreamType.Watts))) { ZoneValueOnDay value = new ZoneValueOnDay(); var ftp = value.GetUserZoneValueOnGivenDate(_userId, enums.ZoneType.BikePower, _fvActivity.Start); if (ftp != null) { BikePower calc = new BikePower(_convertedStream.GetIndividualStream <int?>(enums.StreamType.Watts), ftp.Value); _fvActivity.TSS = calc.TSS(); _fvActivity.IntensityFactor = calc.IntensityFactor(); } } if (_streamSize != null) { _fvActivity.StreamSize = _streamSize; } _fvActivity.DetailsDownloaded = true; _unitOfWork.Complete(); }
public static PeakSeeker CreatePowerCurve(ActivityStreams stream) { var individualStream = stream.GetIndividualStream <int?>(StreamType.Watts) .Select(s => s.Value) .ToList(); return(new PeakSeeker(individualStream, PeakStreamType.Power, stream.ActivityId, true)); }
public static PeakSeeker Create(ActivityStreams stream, StreamType type) { var individualStream = stream.GetIndividualStream <int?>(type) .Select(s => s.Value) .ToList(); PeakStreamType peakStream = type == StreamType.Watts ? PeakStreamType.Power : type == StreamType.Cadence ? PeakStreamType.Cadence : PeakStreamType.HeartRate; return(new PeakSeeker(individualStream, peakStream, stream.ActivityId, false)); }