mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 09:18:48 -03:30
add option to create partitions that span a single minute
* turned on by default currently for testing
This commit is contained in:
@@ -1026,21 +1026,33 @@ def deepmerge(a, b):
|
|||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
def create_partition(start=None, end=None, partition_label=None):
|
def create_partition(start=None, end=None, partition_label=None, minutely=True):
|
||||||
"""Creates new partition tables for events.
|
"""Creates new partition tables for events.
|
||||||
- start defaults to beginning of current hour
|
- start defaults to beginning of current hour
|
||||||
- end defaults to end of current hour
|
- end defaults to end of current hour
|
||||||
- partition_label defaults to YYYYMMDD_HH"""
|
- partition_label defaults to YYYYMMDD_HH
|
||||||
|
|
||||||
|
- minutely will create partitions that span _a single minute_ for testing purposes
|
||||||
|
"""
|
||||||
|
current_time = now()
|
||||||
if not start:
|
if not start:
|
||||||
start = now().replace(microsecond=0, second=0, minute=0)
|
if minutely:
|
||||||
|
start = current_time.replace(microsecond=0, second=0)
|
||||||
|
else:
|
||||||
|
start = current_time.replace(microsecond=0, second=0, minute=0)
|
||||||
if not end:
|
if not end:
|
||||||
end = start.replace(microsecond=0, second=0, minute=0) + timedelta(hours=1)
|
if minutely:
|
||||||
|
end = start.replace(microsecond=0, second=0) + timedelta(minutes=1)
|
||||||
|
else:
|
||||||
|
end = start.replace(microsecond=0, second=0, minute=0) + timedelta(hours=1)
|
||||||
start_timestamp = str(start)
|
start_timestamp = str(start)
|
||||||
end_timestamp = str(end)
|
end_timestamp = str(end)
|
||||||
|
|
||||||
if not partition_label:
|
if not partition_label:
|
||||||
partition_label = start.strftime('%Y%m%d_%H')
|
if minutely:
|
||||||
|
partition_label = start.strftime('%Y%m%d_%H%M')
|
||||||
|
else:
|
||||||
|
partition_label = start.strftime('%Y%m%d_%H')
|
||||||
|
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
# Only partitioning main_jobevent on first pass
|
# Only partitioning main_jobevent on first pass
|
||||||
|
|||||||
Reference in New Issue
Block a user