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

[pm-5966] Fix Entity Framework query for MySQL #5170

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JimmyVo16
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-5966

📔 Objective

Problem: The Entity Framework query was causing a compile-time error.

Changes:

  1. Fixed the query.
  2. Updated the filter to use >= to include all domains from the past 72 hours.
  3. Renamed the variable to replace the comment.

📸 Screenshots

Manual testing

Generated SQL query.
image

With results

image

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

@JimmyVo16 JimmyVo16 requested a review from a team December 19, 2024 21:57
@JimmyVo16 JimmyVo16 self-assigned this Dec 19, 2024
@JimmyVo16 JimmyVo16 requested a review from r-tome December 19, 2024 21:57
.Where(x => (DateTime.UtcNow - x.CreationDate).Days == 4
&& x.VerifiedDate == null)
var unverifiedDomainsInLast72Hours = await dbContext.OrganizationDomains
.Where(x => x.CreationDate.Date >= DateTime.UtcNow.AddDays(-4).Date
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: I'm not sure if a unit test would add value here since the behavior can only be tested at runtime.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can add an integration test on the project Infrastructure.IntegrationTest using the DatabaseData attribute which configures the test to run once for each configured DB provider.
Example here https://github.com/bitwarden/server/blob/main/test/Infrastructure.IntegrationTest/AdminConsole/Repositories/OrganizationRepositoryTests.cs

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 43.33%. Comparing base (11325c4) to head (c4edfc5).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ework/Repositories/OrganizationDomainRepository.cs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5170      +/-   ##
==========================================
- Coverage   43.35%   43.33%   -0.02%     
==========================================
  Files        1456     1458       +2     
  Lines       66468    66491      +23     
  Branches     6078     6078              
==========================================
  Hits        28817    28817              
- Misses      36360    36383      +23     
  Partials     1291     1291              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 19, 2024

Logo
Checkmarx One – Scan Summary & Detailsd6df695a-666d-4326-8c91-5eba6572ea07

No New Or Fixed Issues Found

Copy link
Contributor

@r-tome r-tome left a comment

Choose a reason for hiding this comment

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

It looks good to me but it would be ideal to have the integration test

.Where(x => (DateTime.UtcNow - x.CreationDate).Days == 4
&& x.VerifiedDate == null)
var unverifiedDomainsInLast72Hours = await dbContext.OrganizationDomains
.Where(x => x.CreationDate.Date >= DateTime.UtcNow.AddDays(-4).Date
Copy link
Contributor

Choose a reason for hiding this comment

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

You can add an integration test on the project Infrastructure.IntegrationTest using the DatabaseData attribute which configures the test to run once for each configured DB provider.
Example here https://github.com/bitwarden/server/blob/main/test/Infrastructure.IntegrationTest/AdminConsole/Repositories/OrganizationRepositoryTests.cs

@holow29
Copy link
Contributor

holow29 commented Dec 20, 2024

Looks like this should resolve #3722. Funny to see it resolved because of a compilation issue vs. the longstanding pre-existing issue.

@JimmyVo16 JimmyVo16 requested a review from a team as a code owner December 20, 2024 21:49
@JimmyVo16 JimmyVo16 requested a review from r-tome December 20, 2024 21:49
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.

3 participants