Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to production #117

Merged
merged 26 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
904ab9e
Don't show "submitted by" user email public for privacy reasons. (#88)
Zifah Aug 8, 2024
2d2b9ea
Let the variants list link to the variant name. (#89)
Zifah Aug 8, 2024
127767e
Allow privileged users to manage GeoLocations list. (#91)
Zifah Aug 15, 2024
f7475da
Use the CreateDto in all POST/PUT requests to avoid validation proble…
Zifah Aug 15, 2024
b2a4953
Trim string fields during conversion of request DTOs into entities. (…
Zifah Aug 17, 2024
9c9d442
Feature/publish to twitter (#95)
Zifah Aug 23, 2024
709ebb2
Upgrade deployment workflow for the API to.NET 8 on all environments.…
Zifah Aug 23, 2024
219ad16
Maintenance/ivw prep fixes (#98)
Zifah Aug 26, 2024
6ffa9a9
Prevent name posting service from crashing. (#99)
Zifah Aug 30, 2024
51d1136
Merge branch 'PROD' into main
Zifah Aug 30, 2024
4c758d4
Fix social media sharing tags. (#102)
Zifah Sep 2, 2024
ca905a2
Remove unnecessary encoding of base URL in BasePageModel. (#103)
Zifah Sep 2, 2024
4f0732b
Encode name and meaning for social media sharing. (#104)
Zifah Sep 2, 2024
06e57b1
Replace Task.Delay with PeriodicTimer(). (#101)
Zifah Sep 2, 2024
639648d
Merge branch 'PROD' into main
Zifah Sep 2, 2024
d2795de
Don't Encode Text Parts (#106)
Zifah Sep 2, 2024
5cb47b1
Merge branch 'PROD' into main
Zifah Sep 2, 2024
7f40406
Use Hangfire to schedule tweets. (#108)
Zifah Sep 13, 2024
6c6d1b1
Feature/use distributed caching (#110)
Zifah Sep 16, 2024
6867a3e
Reduce tweet attempts to just 3 (#111)
Zifah Sep 16, 2024
20e1acc
Merge branch 'PROD' into main
Zifah Sep 16, 2024
b22a917
Bugfix/remove limit on popular words (#113)
Zifah Sep 17, 2024
3a05acc
Merge branch 'PROD' into main
Zifah Sep 17, 2024
6e2016b
Extract reusable components from the projects (#115)
Zifah Nov 2, 2024
5f09409
Add an ads.txt file. (#116)
Zifah Dec 24, 2024
089f15d
Resolve merge conflicts.
Zifah Dec 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ardalis.GuardClauses" Version="4.6.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Ardalis.GuardClauses" Version="5.0.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Infrastructure.MongoDB\Infrastructure.MongoDB.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Api/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Api.Utilities;
using Application.Services;
using Core.Dto.Request;
using Core.Dto.Response;
using FluentValidation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Net;
using YorubaOrganization.Core.Dto.Request;
using YorubaOrganization.Core.Dto.Response;

namespace Api.Controllers
{
Expand Down
4 changes: 2 additions & 2 deletions Api/Controllers/EtymologyController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Core.Repositories;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using YorubaOrganization.Core.Repositories;

namespace Api.Controllers
{
Expand Down
16 changes: 7 additions & 9 deletions Api/Controllers/FeedbacksController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Api.Model.Request;
using Application.Domain;
using Application.Services;
using Application.Services;
using Core.Dto.Request;
using Core.Dto.Response;
using Core.Entities.NameEntry.Collections;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
Expand All @@ -27,7 +25,7 @@ public FeedbacksController(NameEntryFeedbackService nameEntryFeedbackService, Na

[HttpGet]
[Route("{id}")]
[ProducesResponseType(typeof(FeedbackDto), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(NameFeedbackDto), (int)HttpStatusCode.OK)]
public async Task<IActionResult> GetById(string id)
{
var feedback = await _nameEntryFeedbackService.GetFeedbackByIdAsync(id);
Expand All @@ -46,7 +44,7 @@ public async Task<IActionResult> GetById(string id)
/// <param name="name">Optional name parameter</param>
/// <returns>A list of all feedback (or just feedback for a given name)</returns>
[HttpGet]
[ProducesResponseType(typeof(List<FeedbackDto>), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(List<NameFeedbackDto>), (int)HttpStatusCode.OK)]
public async Task<IActionResult> GetFeedback([FromQuery] string? name = null)
{
var feedbacks = string.IsNullOrWhiteSpace(name) ? await _nameEntryFeedbackService.FindAllAsync() :
Expand All @@ -64,7 +62,7 @@ public async Task<IActionResult> GetFeedback([FromQuery] string? name = null)
[ProducesResponseType(typeof(Dictionary<string, string>), (int)HttpStatusCode.Created)]
public async Task<IActionResult> Create([FromBody] CreateNameFeedbackDto model)
{
var nameEntry = await _nameEntryService.LoadName(model.Name);
var nameEntry = await _nameEntryService.LoadEntry(model.Name);

if (nameEntry == null)
{
Expand All @@ -91,7 +89,7 @@ public async Task<IActionResult> Delete(string name, string feedbackId)
return BadRequest("Name parameter is required.");
}

var nameEntry = await _nameEntryService.LoadName(name);
var nameEntry = await _nameEntryService.LoadEntry(name);

if (nameEntry == null)
{
Expand Down Expand Up @@ -122,7 +120,7 @@ public async Task<IActionResult> DeleteAll([FromQuery][Required] string name)
return BadRequest("Name parameter is required.");
}

var nameEntry = await _nameEntryService.LoadName(name);
var nameEntry = await _nameEntryService.LoadEntry(name);

if (nameEntry == null)
{
Expand Down
6 changes: 3 additions & 3 deletions Api/Controllers/GeoLocationsController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Api.Utilities;
using Application.Services;
using Core.Dto.Request;
using Core.Dto.Response;
using Core.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Net;
using YorubaOrganization.Core.Dto.Request;
using YorubaOrganization.Core.Dto.Response;
using YorubaOrganization.Core.Entities;

namespace Api.Controllers
{
Expand Down
35 changes: 20 additions & 15 deletions Api/Controllers/NamesController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Api.Model.In;
using Api.Utilities;
using Application.Domain;
using Api.Utilities;
using Application.Mappers;
using Application.Services;
using Core.Dto.Request;
using Core.Dto.Response;
using Core.Entities.NameEntry;
using Core.Enums;
using Core.Entities;
using FluentValidation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MongoDB.Driver;
using System.Net;
using YorubaOrganization.Core.Enums;

namespace Api.Controllers
{
Expand Down Expand Up @@ -63,13 +63,18 @@ public async Task<IActionResult> Post([FromBody] CreateNameDto request)
/// </summary>
/// <returns></returns>
[HttpGet("meta")]
[ProducesResponseType(typeof(NamesMetadataDto[]), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(NamesMetadataDto), (int)HttpStatusCode.OK)]
[AllowAnonymous]
public async Task<IActionResult> GetMetaData()
{
var metaData = await _nameEntryService.GetMetadata();

return Ok(metaData);
return Ok(new NamesMetadataDto
{
TotalNames = metaData.TotalEntries,
TotalPublishedNames = metaData.TotalPublishedEntries,
TotalModifiedNames = metaData.TotalModifiedEntries,
TotalNewNames = metaData.TotalNewEntries
});
}

/// <summary>
Expand All @@ -96,7 +101,7 @@ public async Task<IActionResult> GetAllNames(
IEnumerable<NameEntry> names;
if (all.HasValue && all.Value)
{
names = await _nameEntryService.GetAllNames(state, submittedBy);
names = await _nameEntryService.GetAllEntries(state, submittedBy);
return Ok(names.MapToDtoCollectionMini());
}

Expand All @@ -116,7 +121,7 @@ public async Task<IActionResult> GetAllNames(
[AllowAnonymous]
public async Task<IActionResult> GetName([FromRoute] string name)
{
var nameEntry = await _nameEntryService.LoadName(name);
var nameEntry = await _nameEntryService.LoadEntry(name);

if (nameEntry == null)
{
Expand Down Expand Up @@ -146,22 +151,22 @@ public async Task<IActionResult> UpdateName(string name, [FromBody] UpdateNameDt
return BadRequest(ModelState);
}

var oldNameEntry = await _nameEntryService.LoadName(name);
var oldNameEntry = await _nameEntryService.LoadEntry(name);

if (oldNameEntry == null)
{
return NotFound($"{name} not in database");
}

_ = await _nameEntryService.UpdateName(oldNameEntry, updated.MapToEntity());
_ = await _nameEntryService.Update(oldNameEntry, updated.MapToEntity());
return Ok(new { Message = "Name successfully updated" });
}

[HttpDelete("{name}")]
[Authorize(Policy = "AdminOnly")]
public async Task<IActionResult> DeleteName(string name)
{
var nameEntry = await _nameEntryService.LoadName(name);
var nameEntry = await _nameEntryService.LoadEntry(name);
if (nameEntry == null)
{
return NotFound($"{name} not found in the system so cannot be deleted");
Expand All @@ -177,7 +182,7 @@ public async Task<IActionResult> DeleteName(string name)
public async Task<IActionResult> DeleteNamesBatch(string[] names)
{

var foundNames = (await _nameEntryService.LoadNames(names))?.Select(f => f.Name)?.ToArray();
var foundNames = (await _nameEntryService.LoadEntries(names))?.Select(f => f.Title)?.ToArray();

if (foundNames is null || foundNames.Length == 0)
{
Expand All @@ -186,7 +191,7 @@ public async Task<IActionResult> DeleteNamesBatch(string[] names)

var notFoundNames = names.Where(d => !foundNames.Contains(d)).ToList();

await _nameEntryService.DeleteNamesBatch(foundNames);
await _nameEntryService.DeleteEntriesBatch(foundNames);

string responseMessage = string.Join(", ", foundNames) + " deleted";
if (notFoundNames.Any())
Expand Down
38 changes: 19 additions & 19 deletions Api/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Api.Utilities;
using Application.Domain;
using Application.Mappers;
using Application.Services;
using Core.Cache;
using Core.Dto.Response;
using Core.Entities.NameEntry;
using Core.Enums;
using Core.Events;
using Core.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Net;
using YorubaOrganization.Core.Cache;
using YorubaOrganization.Core.Dto.Response;
using YorubaOrganization.Core.Enums;
using YorubaOrganization.Core.Events;

namespace Api.Controllers
{
Expand Down Expand Up @@ -55,9 +55,9 @@ public async Task<IActionResult> Search([FromQuery(Name = "q"), Required] string
var matches = await _searchService.Search(searchTerm);

// TODO: Check if the comparison here removes takes diacrits into consideration
if (matches.Count() == 1 && matches.First().Name.Equals(searchTerm, StringComparison.CurrentCultureIgnoreCase))
if (matches.Count() == 1 && matches.First().Title.Equals(searchTerm, StringComparison.CurrentCultureIgnoreCase))
{
await _eventPubService.PublishEvent(new ExactNameSearched(matches.First().Name));
await _eventPubService.PublishEvent(new ExactEntrySearched(matches.First().Title));
}

return Ok(matches.MapToDtoCollection());
Expand Down Expand Up @@ -92,11 +92,11 @@ public async Task<IActionResult> SearchByStartsWith(string searchTerm)
[ProducesResponseType(typeof(NameEntryDto), (int)HttpStatusCode.OK)]
public async Task<IActionResult> SearchOne(string searchTerm)
{
NameEntryDto nameEntry = await _searchService.GetName(searchTerm);
var nameEntry = await _searchService.GetName(searchTerm);

if(nameEntry != null)
{
await _eventPubService.PublishEvent(new ExactNameSearched(nameEntry.Name));
await _eventPubService.PublishEvent(new ExactEntrySearched(nameEntry.Name));
}

return Ok(nameEntry);
Expand Down Expand Up @@ -158,7 +158,7 @@ public async Task<IActionResult> GetRecentStats()
[Authorize(Policy = "AdminAndProLexicographers")]
public async Task<IActionResult> PublishName([FromRoute] string name)
{
var nameEntry = await _nameEntryService.LoadName(name);
var nameEntry = await _nameEntryService.LoadEntry(name);
if (nameEntry == null)
{
return BadRequest(ResponseHelper.GetResponseDict($"{name} not found in the repository so not indexed"));
Expand All @@ -170,7 +170,7 @@ public async Task<IActionResult> PublishName([FromRoute] string name)
return BadRequest(ResponseHelper.GetResponseDict($"{name} is already indexed"));
}

await _nameEntryService.PublishName(nameEntry, User!.Identity!.Name!);
await _nameEntryService.PublishEntry(nameEntry, User!.Identity!.Name!);
return StatusCode((int)HttpStatusCode.Created, ResponseHelper.GetResponseDict($"{name} has been published"));
}

Expand All @@ -189,7 +189,7 @@ public async Task<IActionResult> PublishNames([FromBody] string[] names)
// TODO Later: Optimize by fetching all names in one database call instead of one-by-one.
foreach (var name in names)
{
var entry = await _nameEntryService.LoadName(name);
var entry = await _nameEntryService.LoadEntry(name);
if (entry != null && entry.State != State.PUBLISHED)
{
entriesToIndex.Add(entry);
Expand All @@ -204,10 +204,10 @@ public async Task<IActionResult> PublishNames([FromBody] string[] names)
foreach (var nameEntry in entriesToIndex)
{
// TODO Later: The names should be updated in one batch instead of one-by-one.
await _nameEntryService.PublishName(nameEntry, User!.Identity!.Name!);
await _nameEntryService.PublishEntry(nameEntry, User!.Identity!.Name!);
}

var successMessage = $"The following names were successfully indexed: {string.Join(',', entriesToIndex.Select(x => x.Name))}";
var successMessage = $"The following names were successfully indexed: {string.Join(',', entriesToIndex.Select(x => x.Title))}";
return StatusCode((int)HttpStatusCode.Created, ResponseHelper.GetResponseDict(successMessage));
}

Expand All @@ -220,15 +220,15 @@ public async Task<IActionResult> PublishNames([FromBody] string[] names)
[Authorize(Policy = "AdminAndProLexicographers")]
public async Task<IActionResult> UnpublishName([FromRoute] string name)
{
var entry = await _nameEntryService.FindByNameAndState(name, State.PUBLISHED);
var entry = await _nameEntryService.FindByTitleAndState(name, State.PUBLISHED);

if (entry == null)
{
return StatusCode((int)HttpStatusCode.BadRequest, ResponseHelper.GetResponseDict("Published name not found."));
}

entry.State = State.NEW;
await _nameEntryService.UpdateName(entry);
await _nameEntryService.Update(entry);
return Ok(ResponseHelper.GetResponseDict($"{name} removed from index."));
}

Expand All @@ -245,7 +245,7 @@ public async Task<IActionResult> UnpublishNames([FromBody] string[] names)

foreach (var name in names)
{
var entry = await _nameEntryService.FindByNameAndState(name, State.PUBLISHED);
var entry = await _nameEntryService.FindByTitleAndState(name, State.PUBLISHED);

if (entry == null)
{
Expand All @@ -254,8 +254,8 @@ public async Task<IActionResult> UnpublishNames([FromBody] string[] names)
else
{
entry.State = State.UNPUBLISHED;
await _nameEntryService.UpdateName(entry);
unpublishedNames.Add(entry.Name);
await _nameEntryService.Update(entry);
unpublishedNames.Add(entry.Title);
}
}

Expand Down
1 change: 0 additions & 1 deletion Api/Controllers/SuggestedNameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using Application.Mappers;
using Application.Validation;
using FluentValidation;

namespace Api.Controllers;
Expand Down
2 changes: 1 addition & 1 deletion Api/ExceptionHandler/GlobalExceptionHandling.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Api.ExceptionHandler
{
using Api.Utilities;
using Application.Exceptions;
using System.Net;
using System.Text.Json;
using YorubaOrganization.Application.Exceptions;

public class GlobalExceptionHandlingMiddleware
{
Expand Down
Loading
Loading