File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
haystack/management/commands Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,13 @@ def add_arguments(self, parser):
158
158
nargs = "*" ,
159
159
help = "App label of an application to update the search index." ,
160
160
)
161
+ parser .add_argument (
162
+ "-m" ,
163
+ "--minutes" ,
164
+ type = int ,
165
+ default = DEFAULT_AGE / 60 ,
166
+ help = "Number of minutes back to consider objects new." ,
167
+ )
161
168
parser .add_argument (
162
169
"-a" ,
163
170
"--age" ,
@@ -240,6 +247,7 @@ def handle(self, **options):
240
247
self .backends = haystack_connections .connections_info .keys ()
241
248
242
249
age = options .get ("age" , DEFAULT_AGE )
250
+ minutes = options .get ("minutes" , DEFAULT_AGE )
243
251
start_date = options .get ("start_date" )
244
252
end_date = options .get ("end_date" )
245
253
@@ -248,6 +256,12 @@ def handle(self, **options):
248
256
elif self .verbosity > 1 :
249
257
LOG .setLevel (logging .INFO )
250
258
259
+ if (minutes and age ) or (minutes and start_date ) or (age and start_date ):
260
+ raise NotImplementedError ("Minutes / age / start date options are mutually exclusive" )
261
+
262
+ if minutes is not None :
263
+ self .start_date = now () - timedelta (minutes = int (minutes ))
264
+
251
265
if age is not None :
252
266
self .start_date = now () - timedelta (hours = int (age ))
253
267
You can’t perform that action at this time.
0 commit comments