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

Enforce unique speaker names; Use name on export #3018

Merged
merged 20 commits into from
Apr 17, 2024
Merged

Conversation

imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Mar 28, 2024

Resolves #3010


This change is Reviewable

Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 74.66%. Comparing base (5a8006a) to head (f77112b).

Files Patch % Lines
Backend/Services/LiftService.cs 65.71% 7 Missing and 5 partials ⚠️
...rc/components/ProjectUsers/ProjectSpeakersList.tsx 68.42% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3018      +/-   ##
==========================================
+ Coverage   74.25%   74.66%   +0.41%     
==========================================
  Files         269      269              
  Lines       10323    10374      +51     
  Branches     1217     1229      +12     
==========================================
+ Hits         7665     7746      +81     
+ Misses       2306     2271      -35     
- Partials      352      357       +5     
Flag Coverage Δ
backend 83.35% <80.64%> (+0.50%) ⬆️
frontend 66.60% <68.42%> (+0.29%) ⬆️

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.

@imnasnainaec imnasnainaec marked this pull request as ready for review April 1, 2024 19:30
@imnasnainaec imnasnainaec changed the title Speaker uniquer Enforce unique speaker names; Use name on export Apr 2, 2024
@imnasnainaec imnasnainaec marked this pull request as draft April 5, 2024 12:14
@imnasnainaec imnasnainaec marked this pull request as ready for review April 5, 2024 12:50
@imnasnainaec
Copy link
Collaborator Author

imnasnainaec commented Apr 5, 2024

Commit 90fd600 in this pr deals with inconsistent Path.ChangeExtension(path, extension) behavior (in .NET 6) when extension is an empty string: dotnet/runtime#100687

The backend tests of the previous commit (002ca43) fail on Ubuntu 20.02 but not on Windows 11.

Copy link
Collaborator

@jmgrady jmgrady left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 7 files at r1, 10 of 11 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @imnasnainaec)


Backend/Controllers/SpeakerController.cs line 210 at r3 (raw file):

            if (await _speakerRepo.IsSpeakerNameInProject(projectId, name))
            {
                return BadRequest("projectSettings.speaker.nameTaken");

This is a duplicate of the code in CreateSpeaker. Pull out into a separate function so that it is only implemented once.

Code quote:

            // Ensure the new name is valid
            name = name.Trim();
            if (string.IsNullOrEmpty(name))
            {
                return BadRequest("projectSettings.speaker.nameEmpty");
            }
            if (await _speakerRepo.IsSpeakerNameInProject(projectId, name))
            {
                return BadRequest("projectSettings.speaker.nameTaken");

Backend/Services/LiftService.cs line 365 at r3 (raw file):

                var fileExt = Path.GetExtension(src);
                var convertToWav = fileExt.Equals(".webm", StringComparison.OrdinalIgnoreCase);
                fileExt = convertToWav ? ".wav" : fileExt;

This logic seems extra complex. I find this easier to read:

if (fileExt.Equals(".webm", StringComparison.OrdinalIgnoreCase)
{
      fileExt = ".wav";
}

Code quote:

                var convertToWav = fileExt.Equals(".webm", StringComparison.OrdinalIgnoreCase);
                fileExt = convertToWav ? ".wav" : fileExt;

Backend/Services/LiftService.cs line 371 at r3 (raw file):

                {
                    dest = Path.ChangeExtension(dest, fileExt);
                }

This should also be put into a utility function rather than having multiple copies (see below and FileStorage.cs.

Code quote:

                if (!string.IsNullOrEmpty(fileExt))
                {
                    dest = Path.ChangeExtension(dest, fileExt);
                }

public/locales/en/translation.json line 205 at r3 (raw file):

      "enterName": "Enter the name of a new speaker",
      "nameEmpty": "Speaker name is empty",
      "nameTaken": "Speaker name is already taken",

Would it be better to say something like: "Speaker name is already taken in this project"? (or something like that)

Code quote:

      "nameTaken": "Speaker name is already taken",

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: 12 of 14 files reviewed, 2 unresolved discussions (waiting on @jmgrady)


Backend/Controllers/SpeakerController.cs line 210 at r3 (raw file):

Previously, jmgrady (Jim Grady) wrote…

This is a duplicate of the code in CreateSpeaker. Pull out into a separate function so that it is only implemented once.

Done.


Backend/Services/LiftService.cs line 365 at r3 (raw file):

Previously, jmgrady (Jim Grady) wrote…

This logic seems extra complex. I find this easier to read:

if (fileExt.Equals(".webm", StringComparison.OrdinalIgnoreCase)
{
      fileExt = ".wav";
}

The convertToWav was defined to avoid a double if (fileExt.Equals(".webm", StringComparison.OrdinalIgnoreCase) check. (Note the if (convertToWav) below.)

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: 10 of 15 files reviewed, 2 unresolved discussions (waiting on @jmgrady)


Backend/Services/LiftService.cs line 371 at r3 (raw file):

Previously, jmgrady (Jim Grady) wrote…

This should also be put into a utility function rather than having multiple copies (see below and FileStorage.cs.

Done.

Copy link
Collaborator

@jmgrady jmgrady left a comment

Choose a reason for hiding this comment

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

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

@imnasnainaec imnasnainaec enabled auto-merge (squash) April 17, 2024 13:08
Copy link
Collaborator

@jmgrady jmgrady left a 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 r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec)

@imnasnainaec imnasnainaec merged commit 278c72d into master Apr 17, 2024
18 checks passed
@imnasnainaec imnasnainaec deleted the speaker-uniquer branch April 17, 2024 13:16
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.

[Speaker] Require distinct names; Export by name instead of ID
2 participants