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

Add merge status API to fw-headless #1294

Merged
merged 12 commits into from
Dec 6, 2024
Merged

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Nov 29, 2024

Fix #1244.

Creates a new GET /api/crdt-sync-status endpoint.

Currently this returns 404 if the project ID does not match any project in the lexbox database. For all other projects, this returns ReadyToSync unless a CRDT sync is currently in progress, in which case it returns Syncing.

@rmunn rmunn requested a review from hahn-kev November 29, 2024 09:44
@rmunn rmunn self-assigned this Nov 29, 2024
Copy link

github-actions bot commented Nov 29, 2024

C# Unit Tests

98 tests  ±0   98 ✅ ±0   5s ⏱️ ±0s
15 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 0ce3d27. ± Comparison against base commit 94ac2a7.

♻️ This comment has been updated with latest results.

Projects that exist but have never been synced are ready to sync.
Copy link
Contributor

@myieye myieye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is really elegant 👨‍💼 😎

There is something significant missing from the issue though:

This may include "running", "NA", "n changes pending"

I guess if it's not currently syncing, then you somehow calculate how many crdt changes/commits haven't been synced yet (i.e. were added since the last sync). I'm not sure how easy it would be to get the number of hg commits since the last sync, but I'm not sure if @hahn-kev wants that. It would be cool 😆.

backend/FwHeadless/Services/ProjectSyncStatusService.cs Outdated Show resolved Hide resolved
backend/FwHeadless/Services/ProjectSyncStatusService.cs Outdated Show resolved Hide resolved
rmunn added 3 commits December 2, 2024 16:09
It just serves to encapsulate a Dispose() method that does a single
thing, and the Defer.Action() method is perfectly adequate for that.
Next we need to figure out what to do if CurrentProjectService can't
find the project.
@rmunn
Copy link
Contributor Author

rmunn commented Dec 2, 2024

@hahn-kev - Please look at the changes from commit 2649b68, particularly my "This cannot be right, can it?" comment in the changes I just pushed to GetMergeStatus. What's the right approach to opening the CRDT database at that point? I've gotten completely lost in the code again, and I'm pretty sure I need to do something with the ProjectContext.Project object but I have no idea what that something is.

@rmunn rmunn changed the title Feat/fw headless merge status Add merge status API to fw-headless Dec 3, 2024
rmunn added 3 commits December 4, 2024 11:46
Since we don't want to succeed if someone has created a directory with
the name we're looking for, File.Exists is a better approach here.
Rebasing into develop pulled in a change that LfClassicMiniLcmApi didn't
yet implement. Since LF Classic doesn't handle complex forms, the
implementation is dead simple: just return null.
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, I think it's almost done, I think some things could be named better to clarify what they represent

backend/FwHeadless/Program.cs Outdated Show resolved Hide resolved
backend/FwHeadless/Program.cs Show resolved Hide resolved
rmunn added 2 commits December 6, 2024 10:04
It is now called SyncJobStatusService, to better distinguish what it
does vs. what the ProjectSyncStatus represents. The job status only
checks whether there's an active sync job running, while the project
sync status will also check how many commits are on the server waiting
to be synced. (If a sync is running right now, then the answer is 0 and
we can return without hitting the database).
@rmunn rmunn requested a review from hahn-kev December 6, 2024 03:18
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good nice work Robin

@rmunn rmunn merged commit 1b7fd5a into develop Dec 6, 2024
11 checks passed
@rmunn rmunn deleted the feat/fw-headless-merge-status branch December 6, 2024 09:59
Copy link
Contributor

@myieye myieye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least the small open todo's should still be addressed.
But, the functionality and architecture look good to me 👏

Comment on lines +38 to +39
// TODO: Bikeshed this name
public record ProjectSyncStatus(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's perfect 👌

Suggested change
// TODO: Bikeshed this name
public record ProjectSyncStatus(
public record ProjectSyncStatus(

@@ -36,6 +41,13 @@
await next();
});

// Load project ID from request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Or just delete it. But, I believe the comment is inaccurate/out-of-date

Suggested change
// Load project ID from request
// Scope services to the relevant project

@@ -73,6 +87,9 @@ static async Task<Results<Ok<SyncResult>, NotFound, ProblemHttpResult>> ExecuteM
return TypedResults.Ok(new SyncResult(0, 0));
}

syncStatusService.StartSyncing(projectId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 It would be pretty easy to put the number of changes that are being synced in the sync status, so that we can provide that bonus status info during a sync as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FW Headless, check status of merge, restrict one merge for a given project at a time
3 participants