Skip to content

Commit 771e64c

Browse files
authored
SF-3611 Improve speed of adding a source, drafting or training project (#3512)
1 parent 0b0bae6 commit 771e64c

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/SIL.XForge.Scripture/Services/ISFProjectService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Task<QueryResults<EventMetric>> GetEventMetricsAsync(
5959
Task<IReadOnlyList<InviteeStatus>> InvitedUsersAsync(string curUserId, string projectId);
6060
bool IsSourceProject(string projectId);
6161
Task<IEnumerable<TransceleratorQuestion>> TransceleratorQuestionsAsync(string curUserId, string projectId);
62+
63+
[Mutex]
6264
Task SyncUserRoleAsync(string curUserId, string projectId);
6365
Task UpdatePermissionsAsync(
6466
string curUserId,

src/SIL.XForge.Scripture/Services/SFProjectService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,8 +2078,7 @@ private async Task<TranslateSource> GetTranslateSourceAsync(
20782078
else if (updatePermissions)
20792079
{
20802080
// Update all the permissions for all the users on this project or resource
2081-
IDocument<SFProject> projectDoc = await GetProjectDocAsync(sourceProjectRef, conn);
2082-
await UpdatePermissionsAsync(curUserId, projectDoc);
2081+
_backgroundJobClient.Enqueue<ISFProjectService>(r => r.SyncUserRoleAsync(curUserId, sourceProjectRef));
20832082
}
20842083

20852084
return new TranslateSource

test/SIL.XForge.Scripture.Tests/Services/SFProjectServiceTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2788,8 +2788,9 @@ await env.Service.UpdateSettingsAsync(
27882788

27892789
SFProject project = env.GetProject(Project01);
27902790
Assert.That(project.TranslateConfig.Source.ProjectRef, Is.EqualTo(Resource01));
2791+
env.BackgroundJobClient.Received(1).Create(Arg.Any<Job>(), Arg.Any<IState>());
27912792
await env
2792-
.ParatextService.Received(2)
2793+
.ParatextService.Received(1)
27932794
.GetPermissionsAsync(
27942795
Arg.Any<UserSecret>(),
27952796
Arg.Is<SFProject>(p => p.ParatextId == Resource01PTId),

0 commit comments

Comments
 (0)