perf: 优化 csv parse

pull/9942/head
ibuler 2 years ago
parent c4945b3563
commit 4c24e95b47

@ -108,7 +108,7 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel):
verbose_name=_("Nodes"))
is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
labels = models.ManyToManyField('assets.Label', blank=True, related_name='assets', verbose_name=_("Labels"))
info = models.JSONField(verbose_name='Info', default=dict, blank=True) # 资产的一些信息,如 硬件信息
info = models.JSONField(verbose_name=_('Info'), default=dict, blank=True) # 资产的一些信息,如 硬件信息
objects = AssetManager.from_queryset(AssetQuerySet)()

@ -91,7 +91,11 @@ class BaseFileParser(BaseParser):
(col.startswith('[') and col.endswith(']')) or
(col.startswith("{") and col.endswith("}"))
):
col = json.loads(col)
try:
col = json.loads(col)
except json.JSONDecodeError as e:
logger.error('Json load error: ', e)
logger.error('col: ', col)
new_row.append(col)
return new_row

Loading…
Cancel
Save