Updating the way we handle datafiles in the backend #3030
Labels
needs: backend approval
The backend team might not agree on whether this makes sense for the codebase
type: enhancement
New feature or request
work: backend
Related to Python, Django, and simple SQL
Milestone
Problem
Currently we store our data files as objects of the class
DataFile
that looks something like this:This was working perfectly till now. But now that we are expanding our import feature to JSON and Excel files, this class definition needs to be updated.
Problems:
header
,delimiter
,escapechar
andquotechar
are not required while dealing with JSON Files.delimiter
,escapechar
andquotechar
are not required while dealing with Excel Files.max_level
(will be added as an API param for importing JSON) is not required while dealing with CSV and Excel Files.sheet_number
(will be added as API param for importing Excel -- to provide info about sheet number in excel file) is not required while dealing with CSV and JSON files.Proposed solution
We should add more models for handling each of these datafiles, each extending the original datafile model that has core attributes used by all datafiles.
We can add more parameters in the future as we deem necessary for each of the Datafile object. We can check the type of datafile using a simple
isinstance()
method rather than having atype
attribute in theDataFile
model definition.The text was updated successfully, but these errors were encountered: