-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
[NewEntry] If duplicate, add note to existing #1615
Conversation
Hit #1579 while testing this issue. |
src/components/DataEntry/DataEntryTable/DataEntryTable.tsx, line 167 at r1 (raw file):
The frontend does not update the existing field in the Data Entry if a note is added this way. This may be an edge case that is not super important if this is complex to fix. In the following screenshot, I added another |
src/components/DataEntry/DataEntryTable/DataEntryTable.tsx, line 167 at r1 (raw file): Previously, johnthagen wrote…
In review entries, I do see the note added (confirming that the backend is doing the correct thing in the background). |
That may fall in the realm of #1586 |
Backend/Models/Word.cs, line 247 at r1 (raw file):
Perhaps a more explicit name would be |
Backend/Models/Word.cs, line 261 at r1 (raw file):
This can be simplified to: Text += $"[{note.Language}] "; |
Backend/Models/Word.cs, line 261 at r1 (raw file): Previously, johnthagen wrote…
I would actually simplify the entire var langTag = Language != note.Language ? "" : $"[{note.Language}] " ;
Text += $"; {langTag}{note.Text}"; |
Backend/Models/Word.cs, line 261 at r1 (raw file): Previously, johnthagen wrote…
To refactor the whole function to reduce nesting: public void Add(Note note)
{
if (note.IsBlank() || Equals(note))
{
return;
}
if (IsBlank())
{
Language = note.Language;
Text = note.Text;
}
else
{
var langTag = Language != note.Language ? "" : $"[{note.Language}] ";
Text += $"; {langTag}{note.Text}";
}
} |
Backend/Services/WordService.cs, line 1 at r1 (raw file):
Unused import. |
Backend/Services/WordService.cs, line 186 at r1 (raw file):
This comment is not very useful as it duplicates the same information that exists in the next line. Could it be improved or removed? |
Backend.Tests/Models/WordTests.cs, line 128 at r1 (raw file):
Can be |
Codecov Report
@@ Coverage Diff @@
## master #1615 +/- ##
===========================================
+ Coverage 52.37% 80.00% +27.63%
===========================================
Files 272 37 -235
Lines 8321 3456 -4865
Branches 607 0 -607
===========================================
- Hits 4358 2765 -1593
+ Misses 3476 691 -2785
+ Partials 487 0 -487
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Backend.Tests/Models/WordTests.cs, line 132 at r1 (raw file):
Simplify to expectedNote.Text += $"; {newText}"; |
Backend.Tests/Models/WordTests.cs, line 146 at r1 (raw file):
Simplify to expectedNote.Text += $"; [{newLanguage}] {newNote.Text}"; |
Backend/Services/WordService.cs, line 187 at r1 (raw file):
Can we add a test(s) to Another thing that feels a little odd semantically is that This seems like too much going on in one function. We should probably at least change the name to make it obvious that mutation is happening, or (ideally) pull the mutation logic out into a separate function that runs after uniqueness is checked (e.g. |
src/components/DataEntry/DataEntryTable/DataEntryTable.tsx, line 167 at r1 (raw file): Previously, imnasnainaec (D. Ror.) wrote…
Agreed. I added a note to the issue with this condition. |
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.
Reviewed 4 of 4 files at r1.
Reviewable status: 2 of 4 files reviewed, 8 unresolved discussions (waiting on @imnasnainaec and @johnthagen)
Backend/Models/Word.cs, line 247 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend/Models/Word.cs, line 261 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend/Services/WordService.cs, line 1 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend/Services/WordService.cs, line 186 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend.Tests/Models/WordTests.cs, line 128 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend.Tests/Models/WordTests.cs, line 132 at r1 (raw file): Previously, johnthagen wrote…
Done. |
Backend.Tests/Models/WordTests.cs, line 146 at r1 (raw file): Previously, johnthagen wrote…
Done. |
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.
Reviewable status: 1 of 4 files reviewed, 1 unresolved discussion (waiting on @johnthagen)
Backend/Services/WordService.cs, line 187 at r1 (raw file):
Previously, johnthagen wrote…
Can we add a test(s) to
WordServiceTests.cs
to ensure that theService
itself actually adds the Note as expected (i.e. testWordIsUnique
)?Another thing that feels a little odd semantically is that
WordIsUnique
seems like a read-only checking function, but in reality it is now (or maybe it was before as well?) mutating theWord
that is being checked.This seems like too much going on in one function. We should probably at least change the name to make it obvious that mutation is happening, or (ideally) pull the mutation logic out into a separate function that runs after uniqueness is checked (e.g.
UpdateUniqueWord
etc.)
Improved comments. Since the "Audio" side of #1584 will require a refactor of WordIsUnique
(to return more than a boolean, at the very least), splitting the identification of a duplicate and the mutation of the word being duplicated into two functions could be added to that task.
Backend/Services/WordService.cs, line 187 at r1 (raw file): Previously, imnasnainaec (D. Ror.) wrote…
Sounds good. I added a comment to #1584 about this thread. |
Backend/Services/WordService.cs, line 184 at r4 (raw file):
@imnasnainaec Could we still add a test for |
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.
Reviewed 3 of 3 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @imnasnainaec)
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.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @imnasnainaec and @johnthagen)
Backend/Services/WordService.cs, line 184 at r4 (raw file):
Previously, johnthagen wrote…
@imnasnainaec Could we still add a test for
WordServices
that ensures the that theNote
is appended by the service?
Done.
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.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)
The "Note" part of #1584
This change is