(timeline_id, status, error_msg=None)
Helper function to set status for searchindex and all related timelines.

    Args:
        timeline_id: Timeline ID.
        status: Status to set.
        error_msg: Error message.
Helper function to set status for searchindex and all related timelines.
Helper function to set status for searchindex and all related timelines .
def _set_timeline_status(timeline_id, status, error_msg=None):
    """Helper function to set status for searchindex and all related timelines.

    Args:
        timeline_id: Timeline ID.
        status: Status to set.
        error_msg: Error message.
    """
    timeline = Timeline.query.get(timeline_id)

    if not timeline:
        logger.warning('Cannot set status: No such timeline')
        return

    # Check if there is at least one data source that hasn't failed.
    multiple_sources = any(not x.error_message for x in timeline.datasources)

    if multiple_sources:
        timeline_status = timeline.get_status.status.lower()
        if timeline_status != 'process' and status != 'fail':
            timeline.set_status(status)
            timeline.searchindex.set_status(status)
    else:
        timeline.set_status(status)
        timeline.searchindex.set_status(status)

    # Update description if there was a failure in ingestion.
    if error_msg:
        if timeline.datasources:
            data_source = timeline.datasources[-1]
            data_source.error_message = error_msg

    # Commit changes to database
    db_session.add(timeline)
    db_session.commit()
def _set_timeline_status ( timeline_id , status , error_msg = None ) : timeline = Timeline . query . get ( timeline_id ) if not timeline : logger . warning ( 'Cannot set status: No such timeline' ) return # Check if there is at least one data source that hasn't failed. multiple_sources = any ( not x . error_message for x in timeline . datasources ) if multiple_sources : timeline_status = timeline . get_status . status . lower ( ) if timeline_status != 'process' and status != 'fail' : timeline . set_status ( status ) timeline . searchindex . set_status ( status ) else : timeline . set_status ( status ) timeline . searchindex . set_status ( status ) # Update description if there was a failure in ingestion. if error_msg : if timeline . datasources : data_source = timeline . datasources [ - 1 ] data_source . error_message = error_msg # Commit changes to database db_session . add ( timeline ) db_session . commit ( )