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

CSCTTV-4081 Add updated field in Elasticsearch person index #249

Merged
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Move timestamp update logic to userProfileService. Add missing update…
… operations.
sarkikos committed Nov 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 81506bccaeee3de8b89e7eda86fbdd58af974fbf
Original file line number Diff line number Diff line change
@@ -147,9 +147,11 @@ public async Task<IActionResult> PatchMany([FromBody] List<ProfileEditorCooperat
dimUserChoice.UserChoiceValue = profileEditorCooperationItem.Selected;
}
}

await _ttvContext.SaveChangesAsync();

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

return Ok(new ApiResponse(success: true));
}
}
6 changes: 6 additions & 0 deletions aspnetcore/src/api/Controllers/FundingDecisionController.cs
Original file line number Diff line number Diff line change
@@ -163,6 +163,9 @@ public async Task<IActionResult> PostMany([FromBody] List<ProfileEditorFundingDe
}
}

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
await _userProfileService.UpdateProfileInElasticsearch(
@@ -230,6 +233,9 @@ public async Task<IActionResult> RemoveMany([FromBody] List<int> projectIds)
}
await _ttvContext.SaveChangesAsync();

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
await _userProfileService.UpdateProfileInElasticsearch(
5 changes: 2 additions & 3 deletions aspnetcore/src/api/Controllers/ProfileDataController.cs
Original file line number Diff line number Diff line change
@@ -119,9 +119,8 @@ public async Task<IActionResult> PatchMany([FromBody] ProfileEditorDataModificat
profileEditorDataModificationResponse.items.Add(profileEditorItemMeta);
}

// Refresh 'modified' timestamp in table dim_user_profile
string setModifiedSql = _ttvSqlService.GetSqlQuery_Update_DimUserProfile_Modified(userprofileId);
await _userProfileService.ExecuteRawSql(setModifiedSql);
// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
5 changes: 5 additions & 0 deletions aspnetcore/src/api/Controllers/PublicationController.cs
Original file line number Diff line number Diff line change
@@ -184,6 +184,9 @@ public async Task<IActionResult> PostMany([FromBody] List<ProfileEditorPublicati
}
}

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
await _userProfileService.UpdateProfileInElasticsearch(
@@ -247,6 +250,8 @@ public async Task<IActionResult> RemoveMany([FromBody] List<string> publicationI
}
await _ttvContext.SaveChangesAsync();

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
5 changes: 5 additions & 0 deletions aspnetcore/src/api/Controllers/ResearchDatasetController.cs
Original file line number Diff line number Diff line change
@@ -161,6 +161,9 @@ public async Task<IActionResult> PostMany([FromBody] List<ProfileEditorResearchD
}
}

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
await _userProfileService.UpdateProfileInElasticsearch(
@@ -228,6 +231,8 @@ public async Task<IActionResult> RemoveMany([FromBody] List<string> localIdentif
}
await _ttvContext.SaveChangesAsync();

// Refresh 'modified' timestamp in user profile
await _userProfileService.SetModifiedTimestampInUserProfile(userprofileId);

// Update Elasticsearch index.
LogUserIdentification logUserIdentification = this.GetLogUserIdentification();
1 change: 1 addition & 0 deletions aspnetcore/src/api/Services/IUserProfileService.cs
Original file line number Diff line number Diff line change
@@ -47,5 +47,6 @@ public interface IUserProfileService
string GetCMemoryCacheKey_SharePurposes();
string GetCMemoryCacheKey_SharePermissions();
string GetCMemoryCacheKey_GivenPermissions(string orcidId);
Task SetModifiedTimestampInUserProfile(int Id);
}
}
10 changes: 10 additions & 0 deletions aspnetcore/src/api/Services/UserProfileService.cs
Original file line number Diff line number Diff line change
@@ -166,6 +166,16 @@ public async Task<DimUserProfile> GetUserprofileById(int Id)
}
}

/*
* Set 'modified' timestamp in user profile
*/
public async Task SetModifiedTimestampInUserProfile(int Id)
{
await ExecuteRawSql(
_ttvSqlService.GetSqlQuery_Update_DimUserProfile_Modified(Id)
);
}

/*
* Add or update DimName.
*/