Skip to content

Commit 07a201a

Browse files
committed
RockefellerArchiveCenter#170: set cron returns to recent string values
1 parent 750c086 commit 07a201a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

indexer/cron.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
from .indexers import Indexer
66
from .models import IndexRun
77

8+
import json
89

910
class BaseCron(CronJobBase):
1011
RUN_EVERY_MINS = 0
1112
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
1213
clean = False
1314

1415
def do(self):
15-
result = False
16+
result = ''
1617
start = datetime.now()
1718
action = "Full" if self.clean else "Incremental"
1819
object_type = self.object_type if self.object_type else "all"
@@ -21,11 +22,12 @@ def do(self):
2122
try:
2223
indexed = Indexer().add(object_type=self.object_type, clean=self.clean)
2324
except Exception as e:
25+
result = str(e)
2426
print(e)
2527
end = datetime.now()
2628
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)
2931
return result
3032

3133

@@ -92,7 +94,10 @@ class CleanUpCompleted(CronJobBase):
9294

9395
def do(self):
9496
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)
9699
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+

0 commit comments

Comments
 (0)