Skip to content

Conversation

@josecelano
Copy link
Member

@josecelano josecelano commented Sep 14, 2023

Do not allow empty tag names

It was allowed to use empty strings like "" or " " for a tag name.

After merging this PR, it will not be allowed anymore.

If there are some empty names in the database, they are not renamed.

A migration to rename empty names was not added because there can be more than one tag, for example:

  • ""
  • " "
  • " "
  • Etcetera

We could have generated names like "no tag 1", "no tag 2", but it's not likely that admins have created empty tags.

Do not allow duplicate tag names

It was allowed to use empty strings like "" or " " for a tag name. And It was also allowed to have duplicate tags.

After merging this PR, it will not be allowed anymore.

If there are duplicate tag names, the duplication is removed by appending the tag id as a suffix to the tag name.

      It was allowed to use an empty strings like "" or " " for a tag name.

      From now on, it's not allowed.

      If there are some empty names in the database, they are not renamed.

      A migration to rename empty names was not added because there can be more than one tag, for example:

      - ""
      - " "
      - "  "
      - Etcetera

      We could have generated names like "no tag 1", "no tag 2", but it's not likely that admins have created empty tags.
@josecelano josecelano temporarily deployed to coverage September 14, 2023 15:31 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 14, 2023 15:31 — with GitHub Actions Inactive
Duplicate tag names were allowed. This introduce unique constrains.
If there were duyplicate tags they are updated appeding the id as a suffix.
For example, having two tags:

```json
[
  {
    tag_id: 1,
    name: "fractal"
  },
  {
    tag_id: 2,
    name: "fractal"
  }
]
```

They would be renamed to:

```json
[
  {
    tag_id: 1,
    name: "fractal_1"
  },
  {
    tag_id: 2,
    name: "fractal_2"
  }
]
```

From now on, duplicate tags are not allowed.
@josecelano josecelano temporarily deployed to coverage September 14, 2023 17:15 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 14, 2023 17:15 — with GitHub Actions Inactive
@josecelano josecelano requested a review from da2ce7 September 14, 2023 17:17
@josecelano
Copy link
Member Author

ACK 7fedf15

@josecelano josecelano marked this pull request as ready for review September 14, 2023 17:17
@codecov-commenter
Copy link

Codecov Report

Merging #293 (7fedf15) into develop (15ac77d) will increase coverage by 0.18%.
The diff coverage is 61.76%.

@@             Coverage Diff             @@
##           develop     #293      +/-   ##
===========================================
+ Coverage    43.63%   43.81%   +0.18%     
===========================================
  Files           77       77              
  Lines         4325     4346      +21     
===========================================
+ Hits          1887     1904      +17     
- Misses        2438     2442       +4     
Files Changed Coverage Δ
src/databases/database.rs 30.55% <ø> (ø)
src/databases/mysql.rs 0.00% <0.00%> (ø)
...s/from_v1_0_0_to_v2_0_0/databases/sqlite_v2_0_0.rs 81.15% <ø> (ø)
src/databases/sqlite.rs 23.80% <83.33%> (+0.88%) ⬆️
src/errors.rs 19.42% <100.00%> (+2.63%) ⬆️
src/services/tag.rs 87.50% <100.00%> (+9.12%) ⬆️
src/web/api/v1/contexts/tag/handlers.rs 96.55% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@josecelano josecelano merged commit 52926a3 into torrust:develop Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

The API allows adding tags with empty labels (names) and duplicate tags

2 participants