Skip to content

Commit

Permalink
Now use project ID, not code, in CrdtMerge API
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Oct 28, 2024
1 parent ca5d362 commit 987ac61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions backend/CrdtMerge/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@
ProjectsService projectsService,
ProjectLookupService projectLookupService,
CrdtFwdataProjectSyncService syncService,
string projectCode,
Guid projectId,
bool dryRun = false)
{
logger.LogInformation("About to execute sync request for {projectCode}", projectCode);
logger.LogInformation("About to execute sync request for {projectId}", projectId);
if (dryRun)
{
logger.LogInformation("Dry run, not actually syncing");
return TypedResults.Ok(new CrdtFwdataProjectSyncService.SyncResult(0, 0));
}

var projectId = await projectLookupService.GetProjectId(projectCode);
if (projectId is null)
var projectCode = await projectLookupService.GetProjectCode(projectId);
if (projectCode is null)
{
logger.LogError("Project code {projectCode} not found", projectCode);
logger.LogError("Project ID {projectId} not found", projectId);
return TypedResults.NotFound();
}

Expand Down
10 changes: 5 additions & 5 deletions backend/CrdtMerge/ProjectLookupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace CrdtMerge;

public class ProjectLookupService(LexBoxDbContext dbContext)
{
public async ValueTask<Guid?> GetProjectId(string projectCode)
public async ValueTask<string?> GetProjectCode(Guid projectId)
{
var projectId = await dbContext.Projects
.Where(p => p.Code == projectCode)
.Select(p => p.Id)
var projectCode = await dbContext.Projects
.Where(p => p.Id == projectId)
.Select(p => p.Code)
.FirstOrDefaultAsync();
return projectId;
return projectCode;
}
}

0 comments on commit 987ac61

Please sign in to comment.