-
Notifications
You must be signed in to change notification settings - Fork 18
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
Show previous admin user addresses in adminJS #1744
base: staging
Are you sure you want to change the base?
Conversation
WalkthroughThe update significantly enhances the Changes
Sequence Diagram(s)sequenceDiagram
participant Admin as Admin User
participant Project as Project Management
participant Log as Change Log System
Admin->>Project: Update admin user
Project->>Log: Capture previous wallet address
Log->>Log: Generate timestamp using moment()
Log->>Log: Record update in ProjectUpdate table
Log-->>Admin: Confirm update
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (3)
Additional comments not posted (4)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
const changeLog = | ||
'previous admin user address: ' + | ||
project.adminUser.walletAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the previous admin user exists before accessing the wallet address.
The code assumes that project.adminUser
always exists. Add a check to avoid potential runtime errors.
- const changeLog = 'previous admin user address: ' + project.adminUser.walletAddress;
+ const changeLog = project.adminUser
+ ? 'previous admin user address: ' + project.adminUser.walletAddress
+ : 'previous admin user address not available';
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const changeLog = | |
'previous admin user address: ' + | |
project.adminUser.walletAddress; | |
const changeLog = project.adminUser | |
? 'previous admin user address: ' + project.adminUser.walletAddress | |
: 'previous admin user address not available'; |
await ProjectUpdate.insert({ | ||
userId: currentAdmin.id, | ||
projectId: project.id, | ||
content: changeLog, | ||
title: 'admin user changed', | ||
createdAt: moment().toDate(), | ||
isMain: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the ProjectUpdate
insertion handles errors gracefully.
The current code does not handle potential errors during the insertion of the ProjectUpdate
record. Add error handling to ensure robustness.
- await ProjectUpdate.insert({
- userId: currentAdmin.id,
- projectId: project.id,
- content: changeLog,
- title: 'admin user changed',
- createdAt: moment().toDate(),
- isMain: false,
- });
+ try {
+ await ProjectUpdate.insert({
+ userId: currentAdmin.id,
+ projectId: project.id,
+ content: changeLog,
+ title: 'admin user changed',
+ createdAt: moment().toDate(),
+ isMain: false,
+ });
+ } catch (error) {
+ logger.error('Failed to insert project update', error);
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await ProjectUpdate.insert({ | |
userId: currentAdmin.id, | |
projectId: project.id, | |
content: changeLog, | |
title: 'admin user changed', | |
createdAt: moment().toDate(), | |
isMain: false, | |
}); | |
try { | |
await ProjectUpdate.insert({ | |
userId: currentAdmin.id, | |
projectId: project.id, | |
content: changeLog, | |
title: 'admin user changed', | |
createdAt: moment().toDate(), | |
isMain: false, | |
}); | |
} catch (error) { | |
logger.error('Failed to insert project update', error); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
const previousAdminAddress = project.adminUser.walletAddress; | ||
if (previousAdminAddress) { | ||
if (project.adminAddressHistory) { | ||
project.adminAddressHistory.push(previousAdminAddress); | ||
} else { | ||
project.adminAddressHistory = [previousAdminAddress]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the previous admin user exists before accessing the wallet address.
The code assumes that project.adminUser
always exists. Add a check to avoid potential runtime errors.
- const previousAdminAddress = project.adminUser.walletAddress;
+ const previousAdminAddress = project.adminUser ? project.adminUser.walletAddress : null;
+ if (previousAdminAddress) {
+ if (project.adminAddressHistory) {
+ project.adminAddressHistory.push(previousAdminAddress);
+ } else {
+ project.adminAddressHistory = [previousAdminAddress];
+ }
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const previousAdminAddress = project.adminUser.walletAddress; | |
if (previousAdminAddress) { | |
if (project.adminAddressHistory) { | |
project.adminAddressHistory.push(previousAdminAddress); | |
} else { | |
project.adminAddressHistory = [previousAdminAddress]; | |
} | |
} | |
const previousAdminAddress = project.adminUser ? project.adminUser.walletAddress : null; | |
if (previousAdminAddress) { | |
if (project.adminAddressHistory) { | |
project.adminAddressHistory.push(previousAdminAddress); | |
} else { | |
project.adminAddressHistory = [previousAdminAddress]; | |
} | |
} |
#1722
Summary by CodeRabbit
These updates increase transparency and traceability in project management.