Browse Source

Asset stats repository renamed.

pull/336/head
Sebastian Stehle 8 years ago
parent
commit
72df9e0026
  1. 5
      src/Squidex.Domain.Apps.Entities/Assets/AssetStatsRepository.cs
  2. 8
      src/Squidex.Domain.Apps.Entities/Assets/AssetStatsRepository_EventHandling.cs
  3. 8
      src/Squidex.Domain.Apps.Entities/History/HistoryService.cs
  4. 15
      src/Squidex/Config/Domain/EntitiesServices.cs
  5. 4
      src/Squidex/app/features/dashboard/pages/dashboard-page.component.html

5
src/Squidex.Domain.Apps.Entities/Assets/DefaultAssetStatsRepository.cs → src/Squidex.Domain.Apps.Entities/Assets/AssetStatsRepository.cs

@ -11,13 +11,14 @@ using System.Linq;
using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.Repositories;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.UsageTracking;
#pragma warning disable CS0649
namespace Squidex.Domain.Apps.Entities.Assets
{
public partial class DefaultAssetStatsRepository : IAssetStatsRepository
public partial class AssetStatsRepository : IAssetStatsRepository, IEventConsumer
{
private const string Category = "Default";
private const string CounterTotalCount = "TotalAssets";
@ -25,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
private static readonly DateTime SummaryDate;
private readonly IUsageRepository usageStore;
public DefaultAssetStatsRepository(IUsageRepository usageStore)
public AssetStatsRepository(IUsageRepository usageStore)
{
Guard.NotNull(usageStore, nameof(usageStore));

8
src/Squidex.Domain.Apps.Entities/Assets/DefaultAssetStatsRepository_EventHandling.cs → src/Squidex.Domain.Apps.Entities/Assets/AssetStatsRepository_EventHandling.cs

@ -10,11 +10,12 @@ using System.Threading.Tasks;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure.Dispatching;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.UsageTracking;
namespace Squidex.Domain.Apps.Entities.Assets
{
public partial class DefaultAssetStatsRepository
public partial class AssetStatsRepository
{
public string Name
{
@ -26,6 +27,11 @@ namespace Squidex.Domain.Apps.Entities.Assets
get { return "^asset-"; }
}
public Task ClearAsync()
{
return TaskHelper.Done;
}
public Task On(Envelope<IEvent> @event)
{
return this.DispatchActionAsync(@event.Payload, @event.Headers);

8
src/Squidex.Domain.Apps.Entities/History/HistoryService.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NodaTime;
using Squidex.Domain.Apps.Entities.History.Repositories;
using Squidex.Domain.Apps.Events;
using Squidex.Infrastructure;
@ -22,7 +21,6 @@ namespace Squidex.Domain.Apps.Entities.History
private readonly Dictionary<string, string> texts = new Dictionary<string, string>();
private readonly List<IHistoryEventsCreator> creators;
private readonly IHistoryEventRepository repository;
private readonly IClock clock;
public string Name
{
@ -34,13 +32,11 @@ namespace Squidex.Domain.Apps.Entities.History
get { return ".*"; }
}
public HistoryService(IHistoryEventRepository repository, IEnumerable<IHistoryEventsCreator> creators, IClock clock)
public HistoryService(IHistoryEventRepository repository, IEnumerable<IHistoryEventsCreator> creators)
{
Guard.NotNull(repository, nameof(repository));
Guard.NotNull(clock, nameof(clock));
Guard.NotNull(creators, nameof(creators));
this.clock = clock;
this.creators = creators.ToList();
foreach (var creator in this.creators)
@ -66,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.History
historyEvent.Actor = appEvent.Actor;
historyEvent.AppId = appEvent.AppId.Id;
historyEvent.Created = clock.GetCurrentInstant();
historyEvent.Created = @event.Headers.Timestamp();
historyEvent.Version = @event.Headers.EventStreamNumber();
await repository.InsertAsync(historyEvent);

15
src/Squidex/Config/Domain/EntitiesServices.cs

@ -43,6 +43,7 @@ using Squidex.Domain.Apps.Entities.Tags;
using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Diagnostics;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Migrations;
using Squidex.Pipeline;
using Squidex.Pipeline.CommandMiddlewares;
@ -61,6 +62,14 @@ namespace Squidex.Config.Domain
exposeSourceUrl))
.As<IGraphQLUrlGenerator>().As<IRuleUrlGenerator>();
services.AddSingletonAs<HistoryService>()
.As<IEventConsumer>()
.As<IHistoryService>();
services.AddSingletonAs<AssetStatsRepository>()
.As<IEventConsumer>()
.As<IAssetStatsRepository>();
services.AddSingletonAs<CachingGraphQLService>()
.As<IGraphQLService>();
@ -73,18 +82,12 @@ namespace Squidex.Config.Domain
services.AddSingletonAs<AssetQueryService>()
.As<IAssetQueryService>();
services.AddSingletonAs<DefaultAssetStatsRepository>()
.As<IAssetStatsRepository>();
services.AddSingletonAs<ContentQueryService>()
.As<IContentQueryService>();
services.AddSingletonAs<ContentVersionLoader>()
.As<IContentVersionLoader>();
services.AddSingletonAs<HistoryService>()
.As<IHistoryService>();
services.AddSingletonAs<AppHistoryEventsCreator>()
.As<IHistoryEventsCreator>();

4
src/Squidex/app/features/dashboard/pages/dashboard-page.component.html

@ -94,7 +94,7 @@
</div>
<div class="card card-lg">
<div class="card-header">Assets Count</div>
<div class="card-header">Assets Uploads</div>
<div class="card-body">
<chart type="line" [data]="chartStorageCount" [options]="chartOptions"></chart>
</div>
@ -112,7 +112,7 @@
</div>
<div class="card card-lg">
<div class="card-header">Assets Size (MB)</div>
<div class="card-header">Assets Uploads (MB)</div>
<div class="card-body">
<chart type="line" [data]="chartStorageSize" [options]="chartOptions"></chart>
</div>

Loading…
Cancel
Save