Browse Source

fix: csv import progress correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/765/head
Pranav C 3 years ago
parent
commit
86cbeb9a32
  1. 5
      packages/nc-gui/components/project/spreadsheet/components/csvExportImport.vue

5
packages/nc-gui/components/project/spreadsheet/components/csvExportImport.vue

@ -236,9 +236,6 @@ export default {
}) })
const data = this.parsedCsv.data const data = this.parsedCsv.data
for (let i = 0, progress = 0; i < data.length; i += 500) { for (let i = 0, progress = 0; i < data.length; i += 500) {
this.$store.commit('loader/MutMessage', `Importing data : ${progress}/${data.length}`)
this.$store.commit('loader/MutProgress', Math.round(progress && 100 * progress / data.length))
const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => { const batchData = data.slice(i, i + 500).map(row => columnMappings.reduce((res, col) => {
if (col.enabled) { if (col.enabled) {
res[col.destCn] = row[col.sourceCn] res[col.destCn] = row[col.sourceCn]
@ -247,6 +244,8 @@ export default {
}, {})) }, {}))
await api.insertBulk(batchData) await api.insertBulk(batchData)
progress += batchData.length progress += batchData.length
this.$store.commit('loader/MutMessage', `Importing data : ${progress}/${data.length}`)
this.$store.commit('loader/MutProgress', Math.round((100 * progress / data.length)))
} }
this.columnMappingModal = false this.columnMappingModal = false
this.$store.commit('loader/MutClear') this.$store.commit('loader/MutClear')

Loading…
Cancel
Save