Beispiel #1
0
def get_questions(district_name: str):
    spreadsheet = GoogleSpreadSheetCrawler()
    questions_raw = spreadsheet.crawl_spreadsheet(QUESTION_SHEET,
                                                  'Fragen!A2:D')
    questions: List[Question] = [
        Question(info[0], info[2], info[3]) for info in questions_raw
    ]
    only_for_district: List[Question] = [
        question for question in questions
        if question.district == district_name
    ]
    return [question for question in only_for_district]
Beispiel #2
0
def get_public_measures_info(district_name: str):
    state_of_district: str = get_state_for_district(district_name)
    crawler = GoogleSpreadSheetCrawler()
    states_raw = crawler.crawl_spreadsheet(DISTRICT_SHEET,
                                           "Bundeslaender!A2:E")
    states_raw = [state for state in states_raw if len(state) == 5]
    states: List[StateInfo] = [
        StateInfo(state[0], state[1], state[2] == "ja", state[3],
                  state[4] == "ja") for state in states_raw
    ]
    info_for_requested_state: StateInfo = next(
        filter(lambda state_info: state_info.state == state_of_district,
               states))
    return info_for_requested_state
Beispiel #3
0
def get_districts(district_name: str):
    spreadsheet = GoogleSpreadSheetCrawler()
    district_infos = spreadsheet.crawl_spreadsheet(DISTRICT_SHEET,
                                                   'Kreise!A2:F404')
    matching_row = None
    for row in district_infos:
        if row[0] == district_name:
            matching_row = row
    return {
        'district_state': matching_row[1],
        'citizien_hotline': matching_row[2],
        'test_hotline': matching_row[3],
        'info_web_page': matching_row[4],
        'best_practice': matching_row[5]
    }
Beispiel #4
0
def get_districts():
    spreadsheet = GoogleSpreadSheetCrawler()
    district_infos = spreadsheet.crawl_spreadsheet(DISTRICT_SHEET,
                                                   'Kreise!A2:B404')
    district_names = [row[0] for row in district_infos]
    district_states = [row[1] for row in district_infos]

    # with sqlite3.connect(config.DATABASE_PATH) as connection:
    #    c = connection.cursor()
    #    c.execute("""
    #                SELECT name
    #                FROM Districts""")
    #    result = [r[0] for r in c.fetchall()]
    #    connection.close
    return {
        'district_names': district_names,
        'district_states': district_states
    }
Beispiel #5
0
def read_district_case_number(district_name: str):
    #with sqlite3.connect(config.DATABASE_PATH) as connection:
    #    c = connection.cursor()
    #    c.execute("""
    #                SELECT case_number, data_time_stamp
    #                FROM DistrictCaseNumbers
    #                WHERE district_name=?
    #                ORDER BY data_time_stamp DESC""",
    #              (district_name,))
    #    result = c.fetchone()
    #    connection.close
    spreadsheet = GoogleSpreadSheetCrawler()
    all_data = spreadsheet.crawl_spreadsheet(
        '1wg-s4_Lz2Stil6spQEYFdZaBEp8nWW26gVyfHqvcl8s', 'Haupt!A6:S406')
    matching_row = None
    for row in all_data:
        if row[0] == district_name:
            matching_row = row
    return {
        'type': matching_row[1],
        'number_cases': matching_row[3],
        'change_rate': matching_row[4],
        'time': matching_row[9]
    }
Beispiel #6
0
def main():
    sheets_crawler = GoogleSpreadSheetCrawler()
    res = sheets_crawler.crawl_spreadsheet(
        '1wg-s4_Lz2Stil6spQEYFdZaBEp8nWW26gVyfHqvcl8s', 'Haupt!A6:A42')
    print(res)
Beispiel #7
0
def post_question(district_name: str, question: str):
    values: List[List[str]] = [[district_name, "", question, ""]]
    crawler = GoogleSpreadSheetCrawler()
    crawler.post_data(QUESTION_SHEET, "Fragen!A2:D", values)
Beispiel #8
0
def get_state_for_district(district_name: str) -> str:
    crawler = GoogleSpreadSheetCrawler()
    districts = crawler.crawl_spreadsheet(DISTRICT_SHEET, "Kreise!A2:B")
    district: List[str] = next(
        filter(lambda district: district[0] == district_name, districts))
    return district[1]