Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ZOXEXIVO committed Feb 21, 2023
1 parent 78bc1c8 commit 2bebd60
Show file tree
Hide file tree
Showing 182 changed files with 4,144 additions and 4,355 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ steps:
commands:
- docker run -d -p 172.17.0.1:7000:7000 --restart always --name geen-web geen-web:2.0.0.$$DRONE_BUILD_NUMBER
- docker run -d --restart always --name geen-jobs geen-jobs:2.0.0.$$DRONE_BUILD_NUMBER

volumes:
- name: docker_sock
host:
Expand Down
2 changes: 1 addition & 1 deletion build/Jobs.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY ./src/Backend/ ./

WORKDIR /app/Geen.Jobs

RUN dotnet publish -c Release -o /app/out -r linux-x64 --self-contained true /p:PublishReadyToRun=true /p:PublishSingleFile=true --packages packages
RUN dotnet publish -c Release -o /app/out -r linux-x64 --self-contained true /p:PublishSingleFile=true --packages packages

FROM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS runtime
WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions build/Web.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:17-alpine3.14 AS build-frontend
FROM node:19-alpine3.16 AS build-frontend

WORKDIR /app

Expand All @@ -20,7 +20,7 @@ COPY ./src/Backend/ ./

WORKDIR /app/Geen.Web

RUN dotnet publish -c Release -o /app/out -r linux-x64 --self-contained true /p:PublishReadyToRun=true /p:PublishSingleFile=true --packages packages
RUN dotnet publish -c Release -o /app/out -r linux-x64 --self-contained true /p:PublishSingleFile=true --packages packages

FROM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS runtime
WORKDIR /app
Expand Down
23 changes: 11 additions & 12 deletions src/Backend/Geen.Core/Domains/Clubs/ClubModel.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
namespace Geen.Core.Domains.Clubs
namespace Geen.Core.Domains.Clubs;

public class ClubModel
{
public class ClubModel
{
public int Id { get; set; }
public int Id { get; set; }

public string Name { get; set; }
public string UrlName { get; set; }
public string Name { get; set; }
public string UrlName { get; set; }

public string OfficialProfile { get; set; }
public string OfficialProfile { get; set; }

public int LeagueId { get; set; }
public int LeagueId { get; set; }

public bool IsNational { get; set; }
public bool IsNational { get; set; }

public long Votes { get; set; }
}
}
public long Votes { get; set; }
}
31 changes: 15 additions & 16 deletions src/Backend/Geen.Core/Domains/Clubs/Commands/ClubSaveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
using Geen.Core.Domains.Clubs.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Commands
namespace Geen.Core.Domains.Clubs.Commands;

public record ClubSaveCommand : ICommand<Task>
{
public ClubModel Model { get; set; }
}

public class ClubSaveCommandDispatcher : ICommandDispatcher<ClubSaveCommand, Task>
{
public class ClubSaveCommand : ICommand<Task>
private readonly IClubRepository _clubRepository;

public ClubSaveCommandDispatcher(IClubRepository clubRepository)
{
public ClubModel Model { get; set; }
_clubRepository = clubRepository;
}

public class ClubSaveCommandDispatcher : ICommandDispatcher<ClubSaveCommand, Task>
public Task Execute(ClubSaveCommand command)
{
private readonly IClubRepository _clubRepository;

public ClubSaveCommandDispatcher(IClubRepository clubRepository)
{
_clubRepository = clubRepository;
}

public Task Execute(ClubSaveCommand command)
{
return _clubRepository.Save(command.Model);
}
return _clubRepository.Save(command.Model);
}
}
}
54 changes: 27 additions & 27 deletions src/Backend/Geen.Core/Domains/Clubs/Queries/ClubForCacheQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@
using Geen.Core.Domains.Clubs.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Queries
namespace Geen.Core.Domains.Clubs.Queries;

public class ClubsForCacheQuery : IQuery<Task<ConcurrentDictionary<string, ClubModel>>>
{
public class ClubsForCacheQuery : IQuery<Task<ConcurrentDictionary<string, ClubModel>>>
public string ClubUrlName { get; set; }
}

public class
ClubsForCacheQueryHandler : IQueryHandler<ClubsForCacheQuery, Task<ConcurrentDictionary<string, ClubModel>>>
{
private readonly IClubRepository _clubRepository;

public ClubsForCacheQueryHandler(IClubRepository clubRepository)
{
public string ClubUrlName { get; set; }
_clubRepository = clubRepository;
}

public class ClubsForCacheQueryHandler : IQueryHandler<ClubsForCacheQuery, Task<ConcurrentDictionary<string, ClubModel>>>
public async Task<ConcurrentDictionary<string, ClubModel>> Execute(ClubsForCacheQuery query)
{
private readonly IClubRepository _clubRepository;
var items = await _clubRepository.GetCached();

public ClubsForCacheQueryHandler(IClubRepository clubRepository)
{
_clubRepository = clubRepository;
}
var result = new ConcurrentDictionary<string, ClubModel>();

public async Task<ConcurrentDictionary<string, ClubModel>> Execute(ClubsForCacheQuery query)
{
var items = await _clubRepository.GetCached();
foreach (var club in items)
result.TryAdd(GetCleanName(club.Name), club);

var result = new ConcurrentDictionary<string, ClubModel>();

foreach (var club in items)
result.TryAdd(GetCleanName(club.Name), club);

return result;
}
return result;
}

private static string GetCleanName(string clubName)
{
var ind = clubName.IndexOf(' ');
private static string GetCleanName(string clubName)
{
var ind = clubName.IndexOf(' ');

if (ind == -1)
return clubName.ToLower();
if (ind == -1)
return clubName.ToLower();

return clubName.Substring(0, ind).ToLower();
}
return clubName.Substring(0, ind).ToLower();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@
using Geen.Core.Domains.Clubs.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Queries
namespace Geen.Core.Domains.Clubs.Queries;

public class ClubGetAverageAgeQuery : IQuery<Task<double?>>
{
public class ClubGetAverageAgeQuery : IQuery<Task<double?>>
public string UrlName { get; set; }
}

public class ClubGetAverageAgeQueryHandler : IQueryHandler<ClubGetAverageAgeQuery, Task<double?>>
{
private readonly IClubRepository _clubRepository;

public ClubGetAverageAgeQueryHandler(IClubRepository clubRepository)
{
public string UrlName { get; set; }
_clubRepository = clubRepository;
}

public class ClubGetAverageAgeQueryHandler : IQueryHandler<ClubGetAverageAgeQuery, Task<double?>>
public async Task<double?> Execute(ClubGetAverageAgeQuery query)
{
private readonly IClubRepository _clubRepository;
var birthdays = await _clubRepository.GetBirthdays(query.UrlName);

public ClubGetAverageAgeQueryHandler(IClubRepository clubRepository)
{
_clubRepository = clubRepository;
}
if (!birthdays.Any())
return null;

public async Task<double?> Execute(ClubGetAverageAgeQuery query)
{
var birthdays = await _clubRepository.GetBirthdays(query.UrlName);

if (!birthdays.Any())
return null;

return Math.Round(birthdays.Select(GetAge).Average(), 1);
}
return Math.Round(birthdays.Select(GetAge).Average(), 1);
}

private static int GetAge(DateTime dateOfBirth)
{
var today = DateTime.Today;
private static int GetAge(DateTime dateOfBirth)
{
var today = DateTime.Today;

var a = (today.Year * 100 + today.Month) * 100 + today.Day;
var b = (dateOfBirth.Year * 100 + dateOfBirth.Month) * 100 + dateOfBirth.Day;
var a = (today.Year * 100 + today.Month) * 100 + today.Day;
var b = (dateOfBirth.Year * 100 + dateOfBirth.Month) * 100 + dateOfBirth.Day;

return (a - b) / 10000;
}
return (a - b) / 10000;
}
}
}
31 changes: 15 additions & 16 deletions src/Backend/Geen.Core/Domains/Clubs/Queries/ClubGetByIdQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
using Geen.Core.Domains.Clubs.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Queries
namespace Geen.Core.Domains.Clubs.Queries;

public class ClubGetByIdQuery : IQuery<Task<ClubModel>>
{
public int Id { get; set; }
}

public class ClubGetByIdQueryHandler : IQueryHandler<ClubGetByIdQuery, Task<ClubModel>>
{
public class ClubGetByIdQuery : IQuery<Task<ClubModel>>
private readonly IClubRepository _clubRepository;

public ClubGetByIdQueryHandler(IClubRepository clubRepository)
{
public int Id { get; set; }
_clubRepository = clubRepository;
}

public class ClubGetByIdQueryHandler : IQueryHandler<ClubGetByIdQuery, Task<ClubModel>>
public Task<ClubModel> Execute(ClubGetByIdQuery query)
{
private readonly IClubRepository _clubRepository;

public ClubGetByIdQueryHandler(IClubRepository clubRepository)
{
_clubRepository = clubRepository;
}

public Task<ClubModel> Execute(ClubGetByIdQuery query)
{
return _clubRepository.GetById(query.Id);
}
return _clubRepository.GetById(query.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
using Geen.Core.Domains.Clubs.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Queries
namespace Geen.Core.Domains.Clubs.Queries;

public class ClubGetByUrlNameQuery : IQuery<Task<ClubModel>>
{
public string UrlName { get; set; }
}

public class ClubGetByUrlNameQueryHandler : IQueryHandler<ClubGetByUrlNameQuery, Task<ClubModel>>
{
public class ClubGetByUrlNameQuery : IQuery<Task<ClubModel>>
private readonly IClubRepository _clubRepository;

public ClubGetByUrlNameQueryHandler(IClubRepository clubRepository)
{
public string UrlName { get; set; }
_clubRepository = clubRepository;
}

public class ClubGetByUrlNameQueryHandler : IQueryHandler<ClubGetByUrlNameQuery, Task<ClubModel>>
public Task<ClubModel> Execute(ClubGetByUrlNameQuery query)
{
private readonly IClubRepository _clubRepository;

public ClubGetByUrlNameQueryHandler(IClubRepository clubRepository)
{
_clubRepository = clubRepository;
}

public Task<ClubModel> Execute(ClubGetByUrlNameQuery query)
{
return _clubRepository.GetByUrlName(query.UrlName);
}
return _clubRepository.GetByUrlName(query.UrlName);
}
}
}
31 changes: 15 additions & 16 deletions src/Backend/Geen.Core/Domains/Clubs/Queries/ClubGetCoachQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
using Geen.Core.Domains.Players.Repositories;
using Geen.Core.Interfaces.Common;

namespace Geen.Core.Domains.Clubs.Queries
namespace Geen.Core.Domains.Clubs.Queries;

public class ClubGetCoachQuery : IQuery<Task<PlayerModel>>
{
public string ClubUrlName { get; set; }
}

public class ClubGetCoachQueryHandler : IQueryHandler<ClubGetCoachQuery, Task<PlayerModel>>
{
public class ClubGetCoachQuery : IQuery<Task<PlayerModel>>
private readonly IPlayerRepository _playerRepository;

public ClubGetCoachQueryHandler(IPlayerRepository playerRepository)
{
public string ClubUrlName { get; set; }
_playerRepository = playerRepository;
}

public class ClubGetCoachQueryHandler : IQueryHandler<ClubGetCoachQuery, Task<PlayerModel>>
public Task<PlayerModel> Execute(ClubGetCoachQuery query)
{
private readonly IPlayerRepository _playerRepository;

public ClubGetCoachQueryHandler(IPlayerRepository playerRepository)
{
_playerRepository = playerRepository;
}

public Task<PlayerModel> Execute(ClubGetCoachQuery query)
{
return _playerRepository.GetClubCoach(query.ClubUrlName);
}
return _playerRepository.GetClubCoach(query.ClubUrlName);
}
}
}
Loading

0 comments on commit 2bebd60

Please sign in to comment.