Skip to content

Commit

Permalink
Changes to support export on historic incidents
Browse files Browse the repository at this point in the history
  • Loading branch information
Janani Neelamekam committed Dec 19, 2023
1 parent 2907eef commit 09b98c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/dispatch/event/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ def delete_incident_event(
"""Deletes an event."""
event = get_by_uuid(db_session=db_session, uuid=uuid)
log.debug("Deleting incident event")
log.debug(event)
log.debug(event.id)
delete(db_session=db_session, event_id=event.id)


Expand Down Expand Up @@ -298,7 +296,7 @@ def export_timeline(
}
]
if plugin.instance.delete_table(document_id=doc_id, request=delete_table_request):
log.debug("Existing Table in the doc has been deleted")
log.debug("Existing table in the doc has been deleted")

else:
curr_table_start += 1
Expand Down
20 changes: 14 additions & 6 deletions src/dispatch/plugins/dispatch_google/docs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,35 @@ def get_table_details(self, document_id: str, header: str):
header_section = False
table_exists = False
table_indices = []
log.debug(document_content)
headingId = ""
for i, element in enumerate(document_content):
if "paragraph" in element and "elements" in element["paragraph"]:
for item in element["paragraph"]["elements"]:
if "textRun" in item:
if item["textRun"]["content"].strip() == header:
header_index = element["endIndex"]
header_section = True
headingId = element["paragraph"].get("paragraphStyle")["headingId"]

elif header_section:
# Gets the end index of any text below the header
if (
header_section
and item["textRun"]["content"].strip()
and "headingId"
not in element["paragraph"].get("paragraphStyle", {})
and element["paragraph"].get("paragraphStyle")["headingId"]
!= headingId
):
header_index = item["endIndex"]
# checking if we are past header in question
if any(
"headingId" in style
for style in element["paragraph"]["paragraphStyle"]
for style in element["paragraph"].get("paragraphStyle", {})
if (
any(
"headingId" in style
for style in element["paragraph"]["paragraphStyle"]
for style in element["paragraph"].get("paragraphStyle", {})
)
and element["paragraph"].get("paragraphStyle")["headingId"]
!= headingId
):
past_header = True
header_section = False
Expand Down

0 comments on commit 09b98c8

Please sign in to comment.