Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
WE.SpreadsheetImport
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Labels
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
packages
WE.SpreadsheetImport
Commits
886ad68d
Commit
886ad68d
authored
Oct 27, 2016
by
Chivy Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] Force DB persist by specific amount of records
refs KIME-3603
parent
c6ecbfd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
+14
-0
Configuration/Settings.yaml
Configuration/Settings.yaml
+1
-0
No files found.
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
View file @
886ad68d
...
...
@@ -190,6 +190,8 @@ class SpreadsheetImportService {
$identifierProperties
=
$this
->
getDomainMappingIdentifierProperties
();
$file
=
$this
->
spreadsheetImport
->
getFile
()
->
createTemporaryLocalCopy
();
$reader
=
\PHPExcel_IOFactory
::
load
(
$file
);
$numberOfRecordsToPersist
=
$this
->
settings
[
'numberOfRecordsToPersist'
];
$i
=
0
;
/** @var \PHPExcel_Worksheet_Row $row */
foreach
(
$reader
->
getActiveSheet
()
->
getRowIterator
(
2
)
as
$row
)
{
$object
=
$this
->
findObjectByIdentifierPropertiesPerRow
(
$identifierProperties
,
$row
);
...
...
@@ -199,6 +201,7 @@ class SpreadsheetImportService {
$this
->
setObjectPropertiesByRow
(
$object
,
$row
);
$objectRepository
->
update
(
$object
);
$totalUpdated
++
;
$i
++
;
}
else
{
$totalSkipped
++
;
}
...
...
@@ -208,17 +211,28 @@ class SpreadsheetImportService {
$objectRepository
->
add
(
$newObject
);
$objectIds
[]
=
$this
->
persistenceManager
->
getIdentifierByObject
(
$newObject
);
$totalInserted
++
;
$i
++
;
}
else
{
$totalSkipped
++
;
}
if
(
$i
>=
$numberOfRecordsToPersist
)
{
$this
->
persistenceManager
->
persistAll
();
$i
=
0
;
}
}
// remove objects which are not exist on the spreadsheet
if
(
$this
->
spreadsheetImport
->
isDeleting
())
{
$notExistingObjects
=
$this
->
findObjectsByExcludedIds
(
$objectIds
);
$i
=
0
;
foreach
(
$notExistingObjects
as
$object
)
{
$objectRepository
->
remove
(
$object
);
$totalDeleted
++
;
$i
++
;
if
(
$i
>=
$numberOfRecordsToPersist
)
{
$this
->
persistenceManager
->
persistAll
();
$i
=
0
;
}
}
}
...
...
Configuration/Settings.yaml
View file @
886ad68d
WE
:
SpreadsheetImport
:
cleanupImportFromPreviousDay
:
5
numberOfRecordsToPersist
:
100
swisscomGrb
:
domain
:
WE\KIME\Domain\Model\User
Configuration
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment