Skip to content

Commit

Permalink
修改steam游戏总数计算方法,更换周年庆关联文章
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFish-233 committed Jul 11, 2023
1 parent a26b097 commit f4bb0c2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
Expand Up @@ -115,7 +115,9 @@ public async Task<ActionResult<List<EntryInforTipViewModel>>> GetFreeGamesAsync(
[HttpGet]
public async Task<ActionResult<SteamGamesOverviewModel>> GetSteamGamesOverview()
{
if(_overviewModel!=null&&(DateTime.Now.ToCstTime()-_overviewModelUpdateTime).TotalMinutes<10)
var now = DateTime.Now.ToCstTime();

if (_overviewModel!=null&&(now - _overviewModelUpdateTime).TotalMinutes<10)
{
return _overviewModel;
}
Expand All @@ -142,6 +144,11 @@ public async Task<ActionResult<SteamGamesOverviewModel>> GetSteamGamesOverview()

var userCount = await _playedGameRepository.GetAll().AsNoTracking().Include(s => s.ApplicationUser).Where(s => s.IsInSteam && s.ApplicationUser != null).GroupBy(s => s.ApplicationUserId).Where(s => s.Any()).CountAsync();

var gameCount = await _entryRepository.GetAll().AsNoTracking()
.Include(s => s.Releases)
.Where(s => s.PubulishTime != null && s.PubulishTime.Value < now && s.Releases.Any(s => s.PublishPlatformType == PublishPlatformType.Steam && s.Time != null && s.Time.Value < now) && s.IsHidden == false && string.IsNullOrWhiteSpace(s.Name) == false)
.CountAsync();

var games = await _playedGameRepository.GetAll().AsNoTracking().Include(s => s.Entry).Where(s => s.IsInSteam && s.Entry != null && string.IsNullOrWhiteSpace(s.Entry.Name) == false && s.Entry.IsHidden == false)
.GroupBy(s => s.EntryId).Where(s => s.Any()).Select(s => new
{
Expand All @@ -160,11 +167,11 @@ public async Task<ActionResult<SteamGamesOverviewModel>> GetSteamGamesOverview()

_overviewModel= new SteamGamesOverviewModel
{
Count = await _storeInfoRepository.GetAll().AsNoTracking().Where(s => s.PlatformType == PublishPlatformType.Steam && string.IsNullOrWhiteSpace(s.Link) == false).GroupBy(s=>s.EntryId).CountAsync(),
Count = gameCount,
HasMostGamesUsers = usersRe,
PossessionRateHighestGames = highestGames
};
_overviewModelUpdateTime = DateTime.Now.ToCstTime();
_overviewModelUpdateTime = now;

return _overviewModel;
}
Expand Down
Expand Up @@ -15,7 +15,7 @@
{
<span class="d-flex">
<CnGalWebSite.Shared.MasaComponent.Shared.Components.MasaIcon Type="IconType.Count" />
<a href="@Model.Link" target="@(Model.Link.ToLower().Contains("cngal")?"":"_blank")">
<a href="@Model.Link" target="@(Model.Link.ToLower().Contains("http")?"_blank":"")">
@($"{Model.Name} {Model.Count}件")
</a>
</span>
Expand Down
Expand Up @@ -11,14 +11,18 @@

public ArticleViewModel Model { get; set; } = new ArticleViewModel();

[CascadingParameter]
public ErrorHandler ErrorHandler { get; set; }

protected override async Task OnInitializedAsync()
{
try
{
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("1301");
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("2794");
}
catch (Exception exc)
catch (Exception ex)
{
ErrorHandler.ProcessError(ex, "获取获取周年庆活动介绍失败");
}

}
Expand Down
Expand Up @@ -4,12 +4,9 @@
@((MarkupString)Model.MainPage)
</div>



@if (isReady)
{
<CnGalWebSite.Shared.MasaComponent.PC.Comments.CommentTip CanComment CanDeleted="CanDeleted" ObjectId="1220" Type="CommentType.CommentArticle" />

<CnGalWebSite.Shared.MasaComponent.PC.Comments.CommentTip CanComment CanDeleted="CanDeleted" ObjectId="1220" Type="CommentType.CommentArticle" />
}

@code {
Expand All @@ -20,6 +17,9 @@
private Task<AuthenticationState> authenticationStateTask { get; set; }
public ArticleViewModel Model { get; set; } = new ArticleViewModel();

[CascadingParameter]
public ErrorHandler ErrorHandler { get; set; }

protected override async Task OnInitializedAsync()
{
try
Expand All @@ -30,14 +30,12 @@
{
CanDeleted = true;
}
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("1220");
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("2795");
isReady = true;
}
catch (Exception exc)
catch (Exception ex)
{
//isNotFound = true;
//isReady = true;
//StateHasChanged();
ErrorHandler.ProcessError(ex, "获取获取周年庆主页失败");
}

}
Expand Down
Expand Up @@ -10,15 +10,18 @@
@code {
public ArticleViewModel Model { get; set; } = new ArticleViewModel();

[CascadingParameter]
public ErrorHandler ErrorHandler { get; set; }

protected override async Task OnInitializedAsync()
{
try
{
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("1303");
Model = await _dataCatcheService.ArticleIndexPageCatche.GetCache("2796");
}
catch (Exception exc)
catch (Exception ex)
{

ErrorHandler.ProcessError(ex, "获取获取周年庆分享游戏库介绍失败");
}

}
Expand Down
Expand Up @@ -41,7 +41,7 @@
<CnGalWebSite.Shared.MasaComponent.PC.Home.Anniversaries.PlayedGames.MainCard />
</MTabItem>
<MTabItem Value="4">
<CnGalWebSite.Shared.Pages.Webs.Lotteries.Index Id="3" />
<CnGalWebSite.Shared.Pages.Webs.Lotteries.Index Id="10" />
</MTabItem>
<MTabItem Value="5">
<CnGalWebSite.Shared.MasaComponent.PC.Home.Anniversaries.Home.IntroductionCard />
Expand Down

0 comments on commit f4bb0c2

Please sign in to comment.