Skip to content

Commit

Permalink
Merge pull request #239 from InternAcademy/dev
Browse files Browse the repository at this point in the history
Updated Limitations
  • Loading branch information
dpS1lence authored Oct 8, 2024
2 parents c15e589 + e084356 commit 131a1e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static string BuildSystemMessage(UserProfile profile)
sb.Append(profile.DietaryPreference.ToString());
}

//sb.AppendLine(string.Format(UserLanguagePreferencePrompt, profile.InterfacePreference.Language));
sb.AppendLine(string.Format(UserLanguagePreferencePrompt, profile.InterfacePreference.Language));
}

return sb.ToString();
Expand Down
18 changes: 2 additions & 16 deletions src/server/CookingApp/Services/Limitation/LimitationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,16 @@ public async Task<ProcessResult> ProcessUserMessageLimitations(string userId)
}
else if (user.Role.Type == RoleType.Basic)
{
var today = DateTime.UtcNow;
var chatDate = user.Role.Limitations.ChatFromDate;
ArgumentNullException.ThrowIfNull(chatDate, nameof(chatDate));
var endDate = chatDate.Value.AddDays(5);


if (user.Role.Limitations.ChatGeneration > 0)
{
user.Role.Limitations.ChatGeneration--;
await repo.UpdateAsync(user);

return ProcessResult.MessageLimitationSuccessfull;
}
else
{
if (today >= chatDate.Value && today <= endDate)
{
return ProcessResult.MessageLimitationFailed;
}

user.Role.Limitations.ChatFromDate = today;
user.Role.Limitations.ChatGeneration = 20;
await repo.UpdateAsync(user);

return ProcessResult.MessageLimitationSuccessfull;
return ProcessResult.MessageLimitationFailed;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public async Task<ProfileFetchResult> FetchProfile(string userId,IHttpContextAcc
{
var role = CreateRole.Basic(new Limitations
{
ChatGeneration = 20,
ChatGeneration = 40,
ChatFromDate = DateTime.UtcNow,
RecipeGeneration = 2
RecipeGeneration = 3
}, 0, 0);

var profile = new Models.UserProfile
Expand Down

0 comments on commit 131a1e3

Please sign in to comment.