Skip to content

Commit

Permalink
🔍 Optimized configuration retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
muqimjon committed Feb 1, 2024
1 parent 156f319 commit f696e81
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using EcoLink.Application.RepresentationApps.DTOs;

namespace EcoLink.Application.RepresentationApps.Queries.GetRepresentationApp;
namespace EcoLink.Application.RepresentationApps.Queries.GetRepresentationApp;

public record GetAllRepresentationAppsByUserIdQuery : IRequest<IEnumerable<RepresentationAppResultDto>>
{
Expand Down
22 changes: 7 additions & 15 deletions src/backend/EcoLink.Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,19 @@ public static IServiceCollection AddInfrastructureServices(
options.UseNpgsql(configuration.GetConnectionString(name: "DefaultConnection")));

// Add sheets service
#region Add Sheets configure
#region Google Auth Settings converting to json
GoogleAuthSettings googleAuth = new();

var properties = typeof(GoogleAuthSettings).GetProperties();
foreach (var property in properties)
property.SetValue(obj: googleAuth, value: configuration[property.Name] ?? string.Empty);
#endregion

services.AddSingleton(new SheetsConfigure()
services.AddSingleton(implementationInstance: new SheetsConfigure()
{
SpreadsheetId = configuration.GetConnectionString(name: "SpreadsheetId")!,
Service = new SheetsService(new BaseClientService.Initializer()
Service = new SheetsService(initializer: new BaseClientService.Initializer()
{
HttpClientInitializer = GoogleCredential.FromJson(
json: JsonConvert.SerializeObject(googleAuth))
json: JsonConvert.SerializeObject(
value: configuration.GetSection(
key: nameof(GoogleAuthSettings)).
Get<GoogleAuthSettings>())),
}),
Sheets = JsonConvert.DeserializeObject<Sheets>(
value: configuration["Sheets"]!)!
Sheets = configuration.GetSection(key: nameof(Sheets)).Get<Sheets>()!
});
#endregion

// Add repositories
services.AddScoped(serviceType: typeof(IRepository<>), implementationType: typeof(Repository<>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<IActionResult> UpdateStatus(UpdateInvestmentStatusCommand comm
public async Task<IActionResult> Get(long id, CancellationToken cancellationToken)
=> Ok(new Response { Data = await mediator.Send(new GetInvestmentAppQuery(id), cancellationToken) });

[HttpGet("get-all-by-user-user-id/{userId:long}")]
[HttpGet("get-all-by-user-id/{userId:long}")]
[ProducesResponseType(typeof(IEnumerable<InvestmentAppResultDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAllByUserId(long userId, CancellationToken cancellationToken)
=> Ok(new Response { Data = await mediator.Send(new GetAllInvestmentAppsByUserIdQuery(userId), cancellationToken) });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public async Task<IActionResult> Get(long id, CancellationToken cancellationToke
[HttpGet("get-all-by-user-id/{userId:long}")]
[ProducesResponseType(typeof(IEnumerable<RepresentationApp>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAllByUserId(long userId, CancellationToken cancellationToken)
=> Ok(new Response { Data = await mediator.Send(new GetRepresentationAppByIdQuery(userId), cancellationToken) });
=> Ok(new Response { Data = await mediator.Send(new GetAllRepresentationAppsByUserIdQuery(userId), cancellationToken) });
}
4 changes: 2 additions & 2 deletions src/backend/EcoLink.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
},
"Sheets": {
"Investment": "Investment!A:I",
"Entrepreneur": "Entrepreneurship!A:L",
"Representation": "Representation!A:L",
"ProjectManager": "ProjectManagement!A:K"
"Entrepreneurship": "Entrepreneurship!A:L",
"ProjectManagement": "ProjectManagement!A:K"
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task<RepresentationAppDto> GetLastAsync(long id, CancellationToken
if (!response.IsSuccessStatusCode || response.StatusCode is HttpStatusCode.NoContent)
return default!;

var result = await response.Content.ReadFromJsonAsync<Response<IEnumerable<RepresentationAppDto>>>(cancellationToken: cancellationToken);
var result = await response.Content.ReadFromJsonAsync<Response<List<RepresentationAppDto>>>(cancellationToken: cancellationToken);
if (result!.Status == 200)
return result.Data.LastOrDefault()!;

Expand Down
86 changes: 43 additions & 43 deletions src/frontend/EcoLink.Bot/Resources/BotLocalizer.uz.resx
Original file line number Diff line number Diff line change
Expand Up @@ -272,99 +272,99 @@ O'zingiz uchun qulay tilni tanlang: </value>
</data>
<data name="txtApplicationEntrepreneurship" xml:space="preserve">
<value>Ism:
{0}
{0}
Familiya:
{1}
{1}
Yoshi:
{2}
{2}
Ma'lumoti:
{3}
{3}
Ish tajribasi:
{4}
{4}
Loyiha haqida:
{5}
{5}
Yordam turi:
{6}
{6}
Kerakli summa:
{7}
{7}
Tikiladigan aktiv:
{8}
{8}
Telefon raqami:
{9}
{9}
Email:
{10}</value>
{10}</value>
<comment>Tayyor Arizani tasdiqlash uchun foydalanuvchiga to'liq holda taqdim qilish uchun tadbirkor ma'lumotlari</comment>
</data>
<data name="txtApplicationInvestment" xml:space="preserve">
<value>Ism:
{0}
{0}
Familiya:
{1}
{1}
Yoshi:
{2}
{2}
Ma'lumoti:
{3}
{3}
Sektor:
{4}
{4}
Yordam:
{5}
{5}
Telefon raqami:
{6}
{6}
Email:
{7}</value>
{7}</value>
<comment>Tayyor Arizani tasdiqlash uchun foydalanuvchiga to'liq holda taqdim qilish uchun investor ma'lumotlari</comment>
</data>
<data name="txtApplicationProjectManagement" xml:space="preserve">
<value>Ism:
{0}
{0}
Familiya:
{1}
{1}
Yoshi:
{2}
{2}
Ma'lumoti:
{3}
{3}
Til ko'nikmasi:
{4}
{4}
Ish tajribasi:
{5}
{5}
Manzili:
{6}
{6}
Loyiha yo'nalishi:
{7}
{7}
Iqtisodiyot assambleyasidan kutuv:
{8}
{8}
Vakil bo'lishdan maqsad:
{9}
{9}
Telefon raqami:
{10}
{10}
Email:
{11}</value>
{11}</value>
</data>
<data name="txtApplicationRepresentation" xml:space="preserve">
<value>Ism:
{0}
{0}
Familiya:
{1}
{1}
Yoshi:
{2}
{2}
Ma'lumoti:
{3}
{3}
Til ko'nikmasi:
{4}
{4}
Ish tajribasi:
{5}
{5}
Manzili:
{6}
{6}
Vakillik manzili:
{7}
{7}
Iqtisodiyot assambleyasidan kutuv:
{8}
{8}
Vakil bo'lishdan maqsad:
{9}
{9}
Telefon raqami:
{10}
{10}
Email:
{11}</value>
{11}</value>
</data>
<data name="txtAskFeedbackForOrganization" xml:space="preserve">
<value>O'xbekiston Iqtisodiyot Assambleyasi tashkilotining rivoji uchun yana qanday ishlar qilishimiz mumkinligi haqida o'z fikringizni qoldiring. Bu biz uchun juda muhim!</value>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/EcoLink.Bot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
}
},
"AllowedHosts": "*"
}
}

0 comments on commit f696e81

Please sign in to comment.