Skip to content

For non-empty project check, just query database for 1 word#3756

Merged
imnasnainaec merged 6 commits intomasterfrom
nonempty-check
May 9, 2025
Merged

For non-empty project check, just query database for 1 word#3756
imnasnainaec merged 6 commits intomasterfrom
nonempty-check

Conversation

@imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Apr 28, 2025

Resolves #3751

Reduces delay before the Export button in enabled.


This change is Reviewable

@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 72.84%. Comparing base (4761cd9) to head (81d3c7b).
Report is 49 commits behind head on master.

Files with missing lines Patch % Lines
Backend/Controllers/LiftController.cs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3756      +/-   ##
==========================================
- Coverage   72.85%   72.84%   -0.01%     
==========================================
  Files         287      287              
  Lines       10726    10725       -1     
  Branches     1331     1331              
==========================================
- Hits         7814     7813       -1     
  Misses       2517     2517              
  Partials      395      395              
Flag Coverage Δ
backend 81.83% <66.66%> (-0.01%) ⬇️
frontend 65.80% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

using var activity =
OtelService.StartActivityWithTag(otelTagName, "checking if WordsCollection is nonempty");

return await _wordDatabase.Words.Find(GetAllProjectWordsFilter(projectId)).Limit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

might I suggest AnyAsync?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Task<List<Word>> Create(List<Word> words);
Task<Word> Add(Word word);
Task<bool> DeleteAllWords(string projectId);
Task<bool> IsWordsNonempty(string projectId);
Copy link
Contributor

Choose a reason for hiding this comment

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

just a nit pick on the name. Having names in the negative can be tricky to reason about in boolean logic. Additionally the only place you're using this right now is in the negative case, which makes a double negative, so !NonEmpty. it might be more straightforward to change it to IsWordsEmpty then it's IsEmpty or !IsEmpty. If you want to keep the current meaning, I would call it HasWords or AnyWords then you don't have a double negative when you want to see if it's empty.
Feel free to ignore this unsolicited input.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 10 files reviewed, 2 unresolved discussions (waiting on @andracc and @hahn-kev)

Task<List<Word>> Create(List<Word> words);
Task<Word> Add(Word word);
Task<bool> DeleteAllWords(string projectId);
Task<bool> IsWordsNonempty(string projectId);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

using var activity =
OtelService.StartActivityWithTag(otelTagName, "checking if WordsCollection is nonempty");

return await _wordDatabase.Words.Find(GetAllProjectWordsFilter(projectId)).Limit(1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@imnasnainaec imnasnainaec enabled auto-merge (squash) May 8, 2025 16:15
Copy link
Collaborator

@andracc andracc left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 10 files at r2.
Reviewable status: 9 of 10 files reviewed, 3 unresolved discussions (waiting on @hahn-kev and @imnasnainaec)


Backend/Controllers/WordController.cs line 107 at r2 (raw file):

        public async Task<IActionResult> HasFrontierWords(string projectId)
        {
            using var activity = OtelService.StartActivityWithTag(otelTagName, "checking if Frontier is nonempty");

The renaming from "nonempty" is great. Here is another spot for it.

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Dismissed @hahn-kev from 2 discussions.
Reviewable status: 6 of 10 files reviewed, all discussions resolved (waiting on @andracc and @imnasnainaec)

@imnasnainaec imnasnainaec requested a review from andracc May 8, 2025 19:47
Copy link
Collaborator

@andracc andracc left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)

@imnasnainaec imnasnainaec merged commit 5fae576 into master May 9, 2025
18 checks passed
@imnasnainaec imnasnainaec deleted the nonempty-check branch May 9, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve database query for checking if project is empty

3 participants