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

Author type enum #614

Merged
merged 5 commits into from
Feb 28, 2025
Merged

Author type enum #614

merged 5 commits into from
Feb 28, 2025

Conversation

gunnarvelle
Copy link
Member

Innfører enum for ContributorType slik at vi får ordentlig validering på lisensinfo.

Migrerer alt av eksisterende lisenser slik at disse blir i henhold til ny enum. Har også endra validering slik at vi dropper sjekk om type er korrekt siden serialisering vil feile dersom det er feil og dermed vil det aldri treffe valideringa. Innfører heller sjekk på at navn på author er større enn 0.

@gunnarvelle gunnarvelle requested a review from a team February 26, 2025 11:46
@gunnarvelle gunnarvelle force-pushed the author-type-enum branch 2 times, most recently from f13bcb9 to f2f95c4 Compare February 26, 2025 11:55
Comment on lines +46 to +53
private def convertAuthors(authors: List[OldAuthor]): List[Author] = {
authors.map(author => {
ContributorType.valueOf(author.`type`.toLowerCase) match {
case None => Author(ContributorType.mapping(author.`type`.toLowerCase), author.name)
case Some(a) => Author(a, author.name)
}
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Jeg henger ikke helt med på hvorfor denne migreringen trengs jeg.
Er det færre mulige typer nå, eller har de andre navn?
Må vi endre frontend?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nei, vi må ikkje endre frontend. Men vi har en toLower i frontend som vi kan droppe. Hovedpoenget med dette er å få samme verdier overalt. I article og draft er det mest Writer og writer som er forskjellene, men i learningpath er det Forfatter. Dette sikrer at alt er lowercase og kan knyttes til enum.

@gunnarvelle gunnarvelle requested a review from a team February 27, 2025 17:28
|}
|""".stripMargin

val expected = parser.parse(newDocument).toTry.get
Copy link
Member Author

Choose a reason for hiding this comment

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

Synes dette var greit slik så slipper vi å ha expected på ei lang linje.

Copy link
Contributor

@jnatten jnatten left a comment

Choose a reason for hiding this comment

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

Jeg liker det, LGTM!! 💯

@gunnarvelle gunnarvelle merged commit 4fcd1f9 into master Feb 28, 2025
38 checks passed
@gunnarvelle gunnarvelle deleted the author-type-enum branch February 28, 2025 08:01
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.

2 participants