File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 5
5
from .indexers import Indexer
6
6
from .models import IndexRun
7
7
8
+ import json
8
9
9
10
class BaseCron (CronJobBase ):
10
11
RUN_EVERY_MINS = 0
11
12
schedule = Schedule (run_every_mins = RUN_EVERY_MINS )
12
13
clean = False
13
14
14
15
def do (self ):
15
- result = False
16
+ result = ''
16
17
start = datetime .now ()
17
18
action = "Full" if self .clean else "Incremental"
18
19
object_type = self .object_type if self .object_type else "all"
@@ -21,11 +22,12 @@ def do(self):
21
22
try :
22
23
indexed = Indexer ().add (object_type = self .object_type , clean = self .clean )
23
24
except Exception as e :
25
+ result = str (e )
24
26
print (e )
25
27
end = datetime .now ()
26
28
print ("{} records indexed in {}" .format (len (indexed ), end - start ))
27
- print ( "{} index of {} records complete at {}\n " .format (action , object_type , end ) )
28
- result = True
29
+ result = "{} index of {} records complete at {}\n " .format (action , object_type , end )
30
+ print ( result )
29
31
return result
30
32
31
33
@@ -92,7 +94,10 @@ class CleanUpCompleted(CronJobBase):
92
94
93
95
def do (self ):
94
96
try :
95
- return IndexRun .objects .filter (indexrunerror__isnull = True , status = IndexRun .FINISHED ).delete ()
97
+ retval = IndexRun .objects .filter (indexrunerror__isnull = True , status = IndexRun .FINISHED ).delete ()
98
+ result = json .dumps (retval )
96
99
except Exception as e :
97
- print ("Error cleaning up completed IndexRun objects: {}" .format (e ))
98
- return False
100
+ result = "Error cleaning up completed IndexRun objects: {}" .format (e )
101
+ print (result )
102
+ return result
103
+
You can’t perform that action at this time.
0 commit comments