import sys
sys.path.append("..")
from util.utilities import *

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    datefmt='%B-%d-%Y %H:%M:%S',
    filename=f"../logs/{Path(__file__).stem}.log",
    filemode='w'
)

def update_communication_tracker():
    communications = sr_api_pull(
        'communications',
        parameters={
            'school_ids': '15',
            'min_date': '2022-01-03',
            'max_date': datetime.datetime.now().strftime('%Y-%I-%d'),
            'expand': 'communication_method, communication_type, staff_member, student'
        }
    )

    output = [['LCA ID', 'Name', 'Date', 'Staff', 'Method', 'Type', 'Comments']]

    for communication in communications:
        output.append([
            communication['student']['sis_id'],
            f"{communication['student']['first_name']} {communication['student']['last_name']}",
            communication['date'],
            communication['staff_member']['display_name'],
            communication['communication_method']['name'] if communication['communication_method']['name'] != None else '',
            communication['communication_type']['name'] if communication['communication_type']['name'] != None else '',
            communication['comments']
        ])

    update_spreadsheet(
        spreadsheet_name="January '22 Launch",
        sheet_name='communications',
        data=output,
        starting_cell='A1'
    )

if __name__ == '__main__':
    update_communication_tracker()
import sys
sys.path.append("..")
from util.utilities import *

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    datefmt='%B-%d-%Y %H:%M:%S',
    filename=f"../logs/{Path(__file__).stem}.log",
    filemode='w'
)

def update_communication_tracker():
    communications = sr_api_pull(
        'communications',
        parameters={
            'school_ids': '15',
            'min_date': '2022-01-03',
            'max_date': datetime.datetime.now().strftime('%Y-%I-%d'),
            'expand': 'communication_method, communication_type, staff_member, student'
        }
    )

    output = [['LCA ID', 'Name', 'Date', 'Staff', 'Method', 'Type', 'Comments']]

    for communication in communications:
        output.append([
            communication['student']['sis_id'],
            f"{communication['student']['first_name']} {communication['student']['last_name']}",
            communication['date'],
            communication['staff_member']['display_name'],
            communication['communication_method']['name'] if communication['communication_method']['name'] != None else '',
            communication['communication_type']['name'] if communication['communication_type']['name'] != None else '',
            communication['comments']
        ])

    update_spreadsheet(
        spreadsheet_name="January '22 Launch",
        sheet_name='communications',
        data=output,
        starting_cell='A1'
    )

if __name__ == '__main__':
    update_communication_tracker()