Skip to content

Commit affcfd9

Browse files
committed
minutes granularity for update index command
1 parent 4de0687 commit affcfd9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

haystack/management/commands/update_index.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def add_arguments(self, parser):
158158
nargs="*",
159159
help="App label of an application to update the search index.",
160160
)
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+
)
161168
parser.add_argument(
162169
"-a",
163170
"--age",
@@ -240,6 +247,7 @@ def handle(self, **options):
240247
self.backends = haystack_connections.connections_info.keys()
241248

242249
age = options.get("age", DEFAULT_AGE)
250+
minutes = options.get("minutes", DEFAULT_AGE)
243251
start_date = options.get("start_date")
244252
end_date = options.get("end_date")
245253

@@ -248,6 +256,12 @@ def handle(self, **options):
248256
elif self.verbosity > 1:
249257
LOG.setLevel(logging.INFO)
250258

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+
251265
if age is not None:
252266
self.start_date = now() - timedelta(hours=int(age))
253267

0 commit comments

Comments
 (0)