[PM-26967] Added new metric properties#6519
Conversation
|
Claude finished @voommen-livefront's task —— View job Code Review CompleteI've thoroughly reviewed the changes in this PR. Here's my comprehensive assessment: Summary of Changes Since Last ReviewThe most recent commit (d91f92c) addressed SQL formatting issues in both stored procedure files by ensuring proper formatting with square brackets and line breaks as per Bitwarden's code style guidelines. Status of Previously Identified Issues✅ Fixed Issues
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6519 +/- ##
==========================================
+ Coverage 51.86% 55.82% +3.95%
==========================================
Files 1901 1905 +4
Lines 84051 84210 +159
Branches 7501 7510 +9
==========================================
+ Hits 43594 47010 +3416
+ Misses 38763 35423 -3340
- Partials 1694 1777 +83 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
withinfocus
left a comment
There was a problem hiding this comment.
Quick fly-by. I am out of the office for a bit so please re-request team review after updates.
Claude also pointed out several things.
| public string ReportData { get; set; } = string.Empty; | ||
| public string ContentEncryptionKey { get; set; } = string.Empty; | ||
| public string SummaryData { get; set; } = string.Empty; | ||
| public string ApplicationData { get; set; } = string.Empty; | ||
| public int PasswordCount { get; set; } = 0; | ||
| public int PasswordAtRiskCount { get; set; } = 0; | ||
| public int MemberCount { get; set; } = 0; | ||
| public DateTime? CreationDate { get; set; } = null; | ||
| public DateTime? RevisionDate { get; set; } = null; |
There was a problem hiding this comment.
🎨 I wouldn't want defaults on these, and null is not empty (use null). Those strings are nullable too, as are the ints -- why not represent the true default? I wouldn't want code later down the line to see a zero and indicate that's a positive when it's just undefined for example.
There was a problem hiding this comment.
Take a look at all the nullable usage across the PR too.
There was a problem hiding this comment.
updated the usage of nulls. Only using string.Empty where it is required in the code. You are correct - when a request is made, most values may be null.
| RevisionDate = @RevisionDate | ||
| WHERE | ||
| Id = @Id | ||
| AND OrganizationId = @OrganizationId |
There was a problem hiding this comment.
❌ If you have an ID for this exact row I don't see any point in the organization ID being used. I left similar comments in the past -- auth is out of scope for this and the rights to change the row should already be established.
There was a problem hiding this comment.
Thanks for catching this!
withinfocus
left a comment
There was a problem hiding this comment.
The DB changes are fine now but the not-owned-by-me changes still have concerns.
| PasswordCount = organizationReport.PasswordCount ?? 0; | ||
| PasswordAtRiskCount = organizationReport.PasswordAtRiskCount ?? 0; | ||
| MemberCount = organizationReport.MemberCount ?? 0; |
There was a problem hiding this comment.
There was a problem hiding this comment.
I removed the defaults - this time even more carefully reading through the PR - and I think I caught everything, excetpt those that were required by the ITableObject
There was a problem hiding this comment.
I agree that these should be changed. I would make PasswordCount, PasswordAtRiskCount, and MemberCount to have type int? and remove the null-coalescing. Defaulting this to zero creates ambiguity: does 0 mean "we calculated and found zero passwords" or does it mean "we haven't calculated this yet?"
| public string? ApplicationData { get; set; } | ||
|
|
||
| public string ApplicationData { get; set; } | ||
| public OrganizationReportMetricsRequest Metrics { get; set; } = new OrganizationReportMetricsRequest(); |
There was a problem hiding this comment.
There was a problem hiding this comment.
here too - I have removed it as much as possible, except when I absolutely needed it.
There was a problem hiding this comment.
I would make the OrganizationReportMetricRequest nullable and remove it being set.
| public int? ApplicationCount { get; set; } = null; | ||
| public int? ApplicationAtRiskCount { get; set; } = null; | ||
| public int? CriticalApplicationCount { get; set; } = null; | ||
| public int? CriticalApplicationAtRiskCount { get; set; } = null; | ||
| public int? MemberCount { get; set; } = null; | ||
| public int? MemberAtRiskCount { get; set; } = null; | ||
| public int? CriticalMemberCount { get; set; } = null; | ||
| public int? CriticalMemberAtRiskCount { get; set; } = null; | ||
| public int? PasswordCount { get; set; } = null; | ||
| public int? PasswordAtRiskCount { get; set; } = null; | ||
| public int? CriticalPasswordCount { get; set; } = null; | ||
| public int? CriticalPasswordAtRiskCount { get; set; } = null; |
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks for catching this.
There was a problem hiding this comment.
Let's remove setting null. By default in C# value types (e.g. int, bool, etc.) cannot be null. By using the ? operator we are making this a nullable type which allows it to hold null in addition to its normal values. It is really syntactic sugar for Nullable<int> which wraps the value type in a struct that tracks whether a value exists.
mkincaid-bw
left a comment
There was a problem hiding this comment.
Couple minor formatting issues.
| BEGIN | ||
| SET NOCOUNT ON; | ||
|
|
||
| UPDATE dbo.OrganizationReport |
There was a problem hiding this comment.
⛏️ Per the Code Style docs, UPDATE and the table name should be on separate lines.
Also, all object names should include square brackets, ie:
UPDATE
[dbo].[OrganizationReport]
SET
[ApplicationCount] = @ApplicationCount,
[ApplicationAtRiskCount] = @ApplicationAtRiskCount,
...
WHERE
[Id] = @IdThere was a problem hiding this comment.
updated formatting. Sorry I missed this earlier.
| BEGIN | ||
| SET NOCOUNT ON; | ||
|
|
||
| UPDATE dbo.OrganizationReport |
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-26967
📔 Objective
Add properties for metrics within the Repo
Allow the controller to accept metric values and update the database
📸 Screenshots
None
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes