File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,30 +41,13 @@ public function __construct()
4141 */
4242 public function fire ()
4343 {
44- //count number of statements
45- $ count = \Statement::count ();
46-
47- for ($ x = 0 ; $ x <= $ count ; $ x = $ x + 1000 ) {
48-
49- $ skip = $ x ;
50- $ take = 1000 ;
51-
52- //get statements
53- $ statements = \Statement::skip ($ skip )->take ($ take )->get ();
54-
55- if ( $ statements ){
56-
57- foreach ( $ statements as $ s ){
58- //now add timestamp as a date object for mongodb aggregation in document root
59- $ s ->timestamp = new \MongoDate (strtotime ($ s ->statement ['timestamp ' ]));
60- $ s ->save ();
61- }
62-
44+ Statement::chunk (1000 , function ($ statements ){
45+ foreach ($ statements as $ s ){
46+ $ s ->timestamp = new \MongoDate (strtotime ($ s ->statement ['timestamp ' ]));
47+ $ s ->save ();
6348 }
64-
65- $ this ->info ($ x . ' converted ' );
66-
67- }
49+ $ this ->info (count ($ statements ) . ' converted. ' );
50+ });
6851
6952 $ this ->info ('All finished, hopefully! ' );
7053 }
You can’t perform that action at this time.
0 commit comments