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

1700: Refactor and clean up csv import #1765

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

steffenkleinle
Copy link
Member

@steffenkleinle steffenkleinle commented Nov 11, 2024

Short description

Refactor and clean up csv import to avoid implicit side effects.

Proposed changes

  • Move responsibility and code to where it is actually needed
  • Avoid implicit side effects
  • Fix naming

Side effects

  • None.

Testing

Make sure that both normal and freinet CSV import still works.

Resolved issues

Fixes: #1700

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
Copy link
Member Author

Choose a reason for hiding this comment

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

This appeared after setting the eslint configuration in IntelliJ to automatic, I guess we want this project wide then?

@@ -0,0 +1,7 @@
import { ProjectConfig } from '../getProjectConfig'

export const getCsvHeaders = (projectConfig: ProjectConfig): string[] => [
Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think this is good naming? Or should we change this to columnNames or similar?

Copy link
Contributor

@f1sh1918 f1sh1918 Nov 12, 2024

Choose a reason for hiding this comment

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

hm for now i think its okay because it serves this particular purpose and can't be reused that easily. But if we combine name, expiry date and extensions into one array to make it more flexible and to enable better reordering of form fields we might not need to explicitly define here the columns names in the array but just loop through and then we could rename it to getColumnNames

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

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

Looks good!
Nice refactoring 👍

Tested csv import for nuernberg and bavaria

@@ -57,7 +64,7 @@ const ImportCardsInput = ({ setCards, lineToCard, headers, isFreinetFormat }: Im
const lines = content
.split('\n')
.filter(line => line.trim().length)
.map(line => line.split(/,|;/).map(cell => cell.trim()))
.map(line => line.split(/[,;]/).map(cell => cell.trim()))
Copy link
Contributor

Choose a reason for hiding this comment

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

could you explain this change

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.

Refactor freinet CSV import
2 participants