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
82eeab63
Commit
82eeab63
authored
Oct 27, 2016
by
Chivy Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] Add spreadsheet import cleanup command
refs KIME-4682
parent
28a8edde
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
1 deletion
+38
-1
Classes/WE/SpreadsheetImport/Command/SpreadsheetImportCommandController.php
...heetImport/Command/SpreadsheetImportCommandController.php
+25
-0
Classes/WE/SpreadsheetImport/Domain/Model/SpreadsheetImport.php
...s/WE/SpreadsheetImport/Domain/Model/SpreadsheetImport.php
+1
-1
Classes/WE/SpreadsheetImport/Domain/Repository/SpreadsheetImportRepository.php
...tImport/Domain/Repository/SpreadsheetImportRepository.php
+11
-0
Configuration/Settings.yaml
Configuration/Settings.yaml
+1
-0
No files found.
Classes/WE/SpreadsheetImport/Command/SpreadsheetImportCommandController.php
View file @
82eeab63
...
...
@@ -38,6 +38,12 @@ class SpreadsheetImportCommandController extends CommandController {
*/
protected
$persistenceManager
;
/**
* @Flow\InjectConfiguration
* @var array
*/
protected
$settings
;
/**
* Import one pending queued spreadsheet into Domain data, and it will import the next one if it is done
*/
...
...
@@ -70,4 +76,23 @@ class SpreadsheetImportCommandController extends CommandController {
}
}
/**
* Cleanup previous spreadsheet imports by specific time (defined by settings)
*/
public
function
cleanupCommand
()
{
$cleanupImportFromPreviousDay
=
$this
->
settings
[
'cleanupImportFromPreviousDay'
];
$cleanupFromDate
=
new
\DateTime
();
$cleanupFromDate
->
sub
(
new
\DateInterval
(
'P'
.
$cleanupImportFromPreviousDay
.
'D'
));
$oldSpreadsheetImports
=
$this
->
spreadsheetImportRepository
->
findPreviousImportsBySpecificDate
(
$cleanupFromDate
);
if
(
$oldSpreadsheetImports
->
count
()
>
0
)
{
/** @var SpreadsheetImport $oldSpreadsheetImport */
foreach
(
$oldSpreadsheetImports
as
$oldSpreadsheetImport
)
{
$this
->
spreadsheetImportRepository
->
remove
(
$oldSpreadsheetImport
);
}
$this
->
outputLine
(
'%d spreadsheet imports were removed.'
,
array
(
$oldSpreadsheetImports
->
count
()));
}
else
{
$this
->
outputLine
(
'There is no spreadsheet import in queue to remove.'
);
}
}
}
Classes/WE/SpreadsheetImport/Domain/Model/SpreadsheetImport.php
View file @
82eeab63
...
...
@@ -31,7 +31,7 @@ class SpreadsheetImport {
protected
$context
;
/**
* @ORM\OneToOne(cascade={"persist"})
* @ORM\OneToOne(cascade={"persist"
, "remove"
})
* @var \TYPO3\Flow\Resource\Resource
*/
protected
$file
;
...
...
Classes/WE/SpreadsheetImport/Domain/Repository/SpreadsheetImportRepository.php
View file @
82eeab63
...
...
@@ -24,4 +24,15 @@ class SpreadsheetImportRepository extends Repository {
*/
protected
$defaultOrderings
=
array
(
'scheduleDate'
=>
\TYPO3\Flow\Persistence\QueryInterface
::
ORDER_ASCENDING
);
/**
* @param \DateTime $dateTime
*
* @return \TYPO3\Flow\Persistence\QueryResultInterface
*/
public
function
findPreviousImportsBySpecificDate
(
\DateTime
$dateTime
)
{
$query
=
$this
->
createQuery
();
$constraint
=
$query
->
lessThanOrEqual
(
'scheduleDate'
,
$dateTime
);
return
$query
->
matching
(
$constraint
)
->
execute
();
}
}
Configuration/Settings.yaml
View file @
82eeab63
WE
:
SpreadsheetImport
:
cleanupImportFromPreviousDay
:
5
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