-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[600] feat: calculate how many minutes you will need per day/week in …
…order to meet the goal by the end of the year (#601)
- Loading branch information
1 parent
1297b86
commit 1a81b39
Showing
10 changed files
with
118 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Api.Contract; | ||
using Api.Service.Helpers; | ||
using Api.Service.Mappers; | ||
using Common.Dto; | ||
using Peloton.AnnualChallenge; | ||
|
||
namespace Api.Service; | ||
|
||
public interface IPelotonAnnualChallengeService | ||
{ | ||
Task<ServiceResult<ProgressGetResponse>> GetProgressAsync(); | ||
} | ||
|
||
public class PelotonAnnualChallengeService : IPelotonAnnualChallengeService | ||
{ | ||
private readonly IAnnualChallengeService _service; | ||
|
||
public PelotonAnnualChallengeService(IAnnualChallengeService service) | ||
{ | ||
_service = service; | ||
} | ||
|
||
public async Task<ServiceResult<ProgressGetResponse>> GetProgressAsync() | ||
{ | ||
var userId = 1; | ||
var result = new ServiceResult<ProgressGetResponse>(); | ||
|
||
try | ||
{ | ||
var serviceResult = await _service.GetAnnualChallengeProgressAsync(userId); | ||
|
||
if (serviceResult.IsErrored()) | ||
{ | ||
result.Successful = serviceResult.Successful; | ||
result.Error = serviceResult.Error; | ||
return result; | ||
} | ||
|
||
var data = serviceResult.Result; | ||
var tiers = data.Tiers?.Select(t => t.Map()).ToList(); | ||
|
||
result.Result = new ProgressGetResponse() | ||
{ | ||
EarnedMinutes = data.EarnedMinutes, | ||
Tiers = tiers ?? new List<Contract.Tier>(), | ||
}; | ||
|
||
return result; | ||
} | ||
catch (Exception e) | ||
{ | ||
result.Successful = false; | ||
result.Error = new ServiceError() { Exception = e, Message = "Failed to fetch Peloton Annual Challenge data. See logs for more details." }; | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters