def user_wants():
    y = 1
    x = 1
    companies = False
    decision1 = ""
    while y == 1:
        # option to pull multiple companies
        company_pull = input("Which you like to pull for multiple accounts consecutively?\n"
                             "Not for Cohort Analysis, if preforming Cohort pick 2.\nY = 1/ N = 2?")
        if company_pull == "Y" or company_pull == "y" or company_pull == "1":
            companies = True
            x = 2
            y = 2
        elif company_pull == "N" or company_pull == "n" or company_pull == "2":
            x = 1
            y = 2
        else:
            print("Not a viable option, please try again")
    decision1_list = ["1", "2", "3", "4", "5", "6", "7", "8"]
    while x == 1:
        decision1 = input('\nWhat would you like to do today?\n'
                          '1) Find DAU\n'
                          '2) Find MAU\n'
                          '3) Find WAU\n'
                          '4) Find YAU\n'
                          '5) Find DAU/MAU\n'
                          '6) Find WAU/YAU\n'
                          '7) Cohort Analysis\n'
                          '8) Graph, or acquire information from previous pull\n')
        if decision1 not in decision1_list:
            print("That wasn't a viable option, please try again")
        else:
            x = 2
    x = 1
    while x == 1:
        if decision1 == "7":
            cohort_file = input("\nDoes the raw data for a cohert analysis exist in the working directory?\n"
                                "Y = 1/ N = 2:")
            if cohort_file == "1":
                try:
                    cohort_analysis(input('\nWhat is the name of the file?'))
                    data_end_use(pull_type=decision1, data_use=None, account=None)
                    x = 2
                except OSError:
                    print("That file doesn't exist, please try again")
                    x = 1
            elif cohort_file == "2":
                end_date_query(pull_type=decision1, companies=companies, cohorts=True)
                x = 2
            else:
                print("That wasn't a viable option, please try again")
        else:
            end_date_query(pull_type=decision1, companies=companies, cohorts=False)
            x = 2
def what_to_pull(account, account_size, query_end_day, query_end_month, query_end_year, weekend, pull_type, query_size):
    x = 1
    while x == 1:
        if pull_type == "1":  # if DAU is chosen, request the end date and then find DAU
            app_data_daily(month=query_end_month, day=query_end_day, year=query_end_year, weekend=weekend,
                           account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "2":  # if MAU is chosen, request the end date and then find MAU
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=1, weekend=weekend, account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "3":  # if WAU is chosen, request the end date and then find MAU
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=2, weekend=weekend, account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "4":  # if YAU is chosen, request the end date and then find MAU
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=3, weekend=weekend, account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "5":  # if DAU/MAU is chosen, request the end date and then find both
            app_data_daily(month=query_end_month, day=query_end_day, year=query_end_year, weekend=weekend,
                           account=account, query_size=query_size)
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=1, weekend=weekend, account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "6":  # if WAU/YAU is chosen, request the end date and then find both
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=2, weekend=weekend, account=account, query_size=query_size)
            app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                           choice=3, weekend=weekend, account=account, query_size=query_size)
            app_opened(account, invites=account_size)
            x = 2

        elif pull_type == "7":  # if WAU/YAU is chosen, request the end date and then find both
            cohort_pull(month=query_end_month, day=query_end_day, year=query_end_year, account=account,
                        query_size=query_size)
            return

        elif pull_type == "8":  # Use previous pull's data
            pull_type = input('\nWhat information did you use on the last pull?\n'
                              '1) DAU\n'
                              '2) MAU\n'
                              '3) WAU\n'
                              '4) YAU\n'
                              '5) Both DAU & MAU\n'
                              '6) Both WAU & YAU\n'
                              '7) Cohort Analysis\n')
            x = 2
        else:  # Error checking
            print("Wasn't a viable option, please pick again\n")

        python_graph(pull_type=pull_type)  # Creates the Python Graph
        data_end_use(pull_type=pull_type, data_use=None, account=None)
def multiple_companies(query_end_day, query_end_month, query_end_year, weekend, query_size):
    account_amount = 0
    try:
        account_amount = int(input("\nHow many accounts would you like to pull?"))
    except ValueError:
        print("That wasn't a number, please enter a number\n")

    print()
    amount = 0
    account_list = []
    account_invites_list = []
    account_invites = 0
    while amount < account_amount:
        amount += 1
        account = input('Enter account %s: ' % amount)
        if account in account_app_keys:
            account_invites = input('Enter account %s total invites: ' % amount)
            account_list.append(account)
            account_invites_list.append(account_invites)
        else:
            print("That wasn't a viable account, please try again or add to the account dictionary\n")
            amount -= 1
    decision1 = input('\nWhat information did you want to pull?\n'
                      '1) DAU\n'
                      '2) MAU\n'
                      '3) WAU\n'
                      '4) YAU\n'
                      '5) Both DAU & MAU\n'
                      '6) Both WAU & YAU\n')

    decision2 = input('What would you like to do with the information acquired?\n'
                      '1) Dump into a csv\n'
                      '2) Dump into a JSON\n'
                      '3) Create a Plotly graph\n'
                      '4) Nothing\n')

    for account in account_list:
        x = 1
        while x == 1:
            if decision1 == "1":  # if DAU is chosen, request the end date and then find DAU
                app_data_daily(month=query_end_month, day=query_end_day, year=query_end_year, weekend=weekend,
                               account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2

            elif decision1 == "2":  # if MAU is chosen, request the end date and then find MAU
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=1, weekend=weekend, account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2

            elif decision1 == "3":  # if WAU is chosen, request the end date and then find MAU
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=2, weekend=weekend, account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2

            elif decision1 == "4":  # if YAU is chosen, request the end date and then find MAU
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=3, weekend=weekend, account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2

            elif decision1 == "5":  # if DAU/MAU is chosen, request the end date and then find both
                app_data_daily(month=query_end_month, day=query_end_day, year=query_end_year, weekend=weekend,
                               account=account, query_size=query_size)
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=1, weekend=weekend, account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2

            elif decision1 == "6":  # if WAU/YAU is chosen, request the end date and then find both
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=2, weekend=weekend, account=account, query_size=query_size)
                app_data_weekly_monthly_yearly(month=query_end_month, day=query_end_day, year=query_end_year,
                                               choice=3, weekend=weekend, account=account, query_size=query_size)
                data_end_use(pull_type=decision1, data_use=decision2, account=account)
                app_opened(account, invites=account_invites)
                x = 2
            else:  # Error checking
                print("Wasn't a viable option, please pick again\n")