diff --git a/api/db.py b/api/db.py index 978be47..730812e 100644 --- a/api/db.py +++ b/api/db.py @@ -1,5 +1,6 @@ -from datetime import datetime,date +from datetime import datetime, date from functools import lru_cache +import itertools import json import logging from typing_extensions import Annotated @@ -10,17 +11,21 @@ import config -import re from fastapi import Depends from fastapi import responses from fastapi import encoders from typing import List, Dict +from fastapi import responses +from fastapi import encoders +from typing import List, Dict + +from decimal import Decimal from decimal import Decimal logger = logging.getLogger(__name__) -ITTER_SIZE=500 +ITTER_SIZE = 500 @lru_cache @@ -41,10 +46,37 @@ def get_db_connection( @contextmanager -def get_db_cursor(): +def get_db_cursor(cursor_name: str = 'oknesset'): conn = get_db_connection(get_settings()) - # Named cursor to be able stream data from database - cur = conn.cursor(name='oknesset',cursor_factory=RealDictCursor) + """ + Context manager for acquiring and using a database cursor. + + This function returns a context manager that can be used with the `with` statement + to acquire a database cursor, execute operations, and automatically close the cursor + and connection when the block is exited. + + Usage: + ``` + with get_db_cursor() as cursor: + # Perform database operations using the cursor + cursor.execute("SELECT * FROM your_table") + result = cursor.fetchall() + # Do something with the result + + # Cursor and connection are automatically closed outside the 'with' block + ``` + + Returns: + psycopg2.extensions.cursor: A database cursor with a RealDictCursor factory. + + Raises: + Exception: Any exception that may occur during the acquisition of the cursor or + execution of operations within the 'with' block. + """ + if cursor_name: + cur = conn.cursor(name=cursor_name, cursor_factory=RealDictCursor) + else: + cur = conn.cursor(cursor_factory=RealDictCursor) try: yield cur finally: @@ -52,154 +84,597 @@ def get_db_cursor(): conn.close() -# get single data from table -def get_single_data(table, field, value): +def get_single_data(table: str, field: str, value: int): + """ + Retrieve a single record from the specified database table based on the provided criteria. + + This function executes a SELECT query on the specified table, using the provided field and value + to filter the results. It returns the first matching record or raises an exception if no match is found. + + Usage: + ``` + try: + result = get_single_data("your_table", "your_field", "desired_value") + # Do something with the result + except TypeError as e: + print(f"Error: {e}") + ``` + + Args: + - table (str): The name of the database table to query. + - field (str): The field in the table to use as a filter. + - value (int): The value to match in the specified field. + + Returns: + dict: A dictionary representing the first matching record in the specified table. + + Raises: + TypeError: If no data is found matching the specified criteria. + + """ sql = f'select * from {table} where "{field}"={value}' - with get_db_cursor() as cur: - cur.execute(sql) - data = cur.fetchone() - if data is None: - return TypeError('No such data exists!') + try: + with get_db_cursor() as cur: + cur.execute(sql) + data = cur.fetchone() + if data is None: + return TypeError( + 'No such data exists! Please enter another ID') + except Exception as e: + logger.critical("critical error", e) return data -# get all known info about current minister or knesset member -def get_fully_today_member(query, value=None): +def get_fully_today_member(query: str, value: int): + """ + Retrieve all known information about the current minister or Knesset member based on the provided query. + + This function executes a custom query on the database to retrieve information about the current minister or + Knesset member. The query and optional value are used to filter the results. It returns a dictionary with the + known information about the member or raises an exception if no match is found. + + Usage: + ``` + try: + result = get_fully_today_member("SELECT * FROM your_table WHERE condition = %s", ("desired_value",)) + # Do something with the result + except ValueError as e: + print(f"Error: {e}") + ``` + + Args: + - query (str): The SQL query to execute for retrieving member information. + - value (int): The value to be used in the query as a parameter. + + Returns: + dict: A dictionary containing all known information about the current minister or Knesset member. + + Raises: + TypeError: If no member is found based on the provided query and value. + + """ try: with get_db_cursor() as cur: cur.execute(query, value) data = cur.fetchone() if data is None: - raise ValueError('No such member exist!') + return TypeError( + 'No such member exist! Please enter another ID') except Exception as e: - return e + logger.critical("critical error", e) return data -# Get info about knesset members -# is_current = true --> current Knesset members -# is_current = false --> inactive Knesset members -# knesset_num --> Knesset period of the Knesset member -def get_members(query,is_current:bool,knesset_num:int): + +def get_members(query, is_current: bool, knesset_term: int = None): + """ + Retrieve information about members based on the provided query, current status, and Knesset number. + + This function executes a custom query on the database to retrieve information about members based on the + specified criteria. The 'query' parameter defines the SQL query to execute, 'is_current' is a boolean + indicating whether to retrieve current or past members, and 'knesset_num' is an optional parameter + specifying the Knesset number for filtering. + + Usage: + ``` try: - with get_db_cursor() as cur: + result = get_members("SELECT * FROM your_table WHERE condition = %s", is_current=True, knesset_num=24) + # Do something with the result + except Exception as e: + print(f"Error: {e}") + ``` + + Args: + - query (str): The SQL query to execute for retrieving member information. + - is_current (bool): A boolean indicating whether to retrieve information about current members. + - knesset_num (int, optional): The Knesset number for filtering members. If not provided, the function + retrieves information for the latest Knesset. + + Returns: + list: A list of dictionaries containing information about members based on the query and criteria. + + Raises: + Exception: Any exception that may occur during the execution of the query. + + """ + try: + with get_db_cursor('max') as cur_max, get_db_cursor('data') as cur_data: if is_current: - if(knesset_num==None): - cur.execute('select max("KnessetNum") from knesset_kns_knessetdates') - knesset_number = cur.fetchone() - is_current_params=(knesset_number['max'], - knesset_number['max'], - knesset_number['max'], - knesset_number['max'], - is_current) - cur.execute(query,is_current_params) - data = cur.fetchall() + if (knesset_term is None): + cur_max.execute( + 'select max("KnessetNum") from knesset_kns_knessetdates') + knesset_term = cur_max.fetchone()['max'] + cur_data.execute( + query, { + 'is_current': is_current, 'knesset_term': knesset_term}) + data = cur_data.fetchall() else: - is_current_params=(knesset_num, - knesset_num, - knesset_num, - knesset_num, - is_current) - cur.execute(query,is_current_params) - data = cur.fetchall() - + cur_data.execute( + query, { + 'is_current': is_current, 'knesset_term': knesset_term}) + data = cur_data.fetchall() + else: - is_current_params=(knesset_num, - knesset_num, - knesset_num, - knesset_num, - is_current) - cur.execute(query,is_current_params) - data = cur.fetchall() + cur_data.execute( + query, { + 'is_current': is_current, 'knesset_term': knesset_term}) + data = cur_data.fetchall() except Exception as e: - return e + logger.critical("critical error", e) return data -# Get info about some Knesset member -def get_members_info(query,mk_individual_id:int): + +def get_member(query, mk_individual_id: int, knesset_term: int = None): + """ + Retrieve information about a member of the Knesset (Israeli Parliament) based on the provided query. + + Parameters: + - query (str): SQL query to fetch data from the database. + - mk_individual_id (int): The unique identifier for the member of Knesset. + - knesset_term (int, optional): The Knesset term for which the information is requested. + If not provided, the function will automatically use the latest available term. + + Returns: + dict: A dictionary containing information about the member of Knesset, or None if no data is found. + + Note: + If an error occurs during the execution, a critical error message is logged, and the function returns None. + + Example: + ``` + result = get_member(query, mk_individual_id=123, knesset_term=24) + ``` + + """ try: - with get_db_cursor() as cur: - cur.execute(query) - data = cur.fetchall() - # Two options: - # 1. No such 'mk_individual_id' in database - # 2. 'mk_individual_id' exist but no data for him - if (not(is_mk_individual_exist(mk_individual_id)) - or len(data) == 0 ): - return TypeError('No such data exists!') + # Using two different cursors not not get error with execute more than + # once + with get_db_cursor('max') as cur_max, get_db_cursor('data') as cur_data: + if (knesset_term is None): + cur_max.execute( + 'select max("KnessetNum") as max_term from knesset_kns_knessetdates') + knesset_term = cur_max.fetchone()['max_term'] + cur_data.execute(query, + {'mk_individual_id': mk_individual_id, + 'knesset_term': knesset_term}) + data = cur_data.fetchone() + if not (is_mk_individual_exist(mk_individual_id)): + return TypeError( + 'No such data exists! Please enter another ID') + elif not (is_knesset_term_exist(knesset_term)): + return TypeError( + 'No such data exists! Please enter another Knesset term') + except Exception as e: + logger.critical("critical error", e) + return data + + +def get_member_by_committee(committee: int | str): + """ + Retrieve distinct member IDs associated with a specified committee. + + Parameters: + - committee (int | str): Either the committee ID (if int) or a string representing part or all of the committee name. + + Returns: + - list: A list of distinct member IDs associated with the specified committee. + + Examples: + ``` + # Example 1: Retrieve individual IDs for members of committee with ID 101 + members_ids = get_member_by_committee(101) + + # Example 2: Retrieve individual IDs for members of committee with name 'Finance Committee' + members_ids = get_member_by_committee('Finance Committee') + ``` + """ + try: + with get_db_cursor('data') as cur_data: + if isinstance(committee, int): + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_committees where committee_id = %s", + (committee, + )) + else: + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_committees where committee_name like '%{committee}%'", + (committee, + )) + data = cur_data.fetchall() + except Exception as e: + logger.critical("critical error", e) + return data + + +def get_member_by_faction(faction: int | str): + """ + Retrieve distinct member IDs associated with a specified faction. + + Parameters: + - faction (int | str): Either the faction ID (if int) or a string representing part or all of the faction name. + + Returns: + - list: A list of distinct member IDs associated with the specified faction. + + Examples: + ``` + # Example 1: Retrieve individual IDs for members of faction with ID 42 + members_ids_1 = get_member_by_faction(42) + + # Example 2: Retrieve individual IDs for members of faction with name 'Finance' + members_ids_2 = get_member_by_faction('Finance') + ``` + """ + try: + with get_db_cursor('data') as cur_data: + if isinstance(faction, int): + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_factions where faction_id = %(faction_id)s", { + "faction_id": faction}) + else: + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_factions where faction_name like %(faction_name)s", { + "faction_name": '%' + faction + '%'}) + data = cur_data.fetchall() + except Exception as e: + logger.critical("critical error", e) + return data + + +def get_member_by_faction_chairperson(faction: int | str): + """ + Retrieves a list of distinct individual IDs associated with members who have served as chairpersons + of the specified faction. + + Parameters: + - faction (int | str): The identifier (ID) or name of the faction to retrieve members for. + If an integer is provided, it is treated as the faction ID; if a string is provided, + it is treated as a case-insensitive search for the faction name. + + Returns: + - list: A list of distinct individual IDs associated with members who served as chairpersons of the specified faction. + + Example: + ``` + # Retrieve individual IDs for members of faction with ID 42 + members_ids = get_member_by_faction_chairperson(42) + + # Retrieve individual IDs for members of faction with name 'Finance' + members_ids = get_member_by_faction_chairperson('Finance') + ``` + """ + try: + with get_db_cursor() as cur_data: + if isinstance(faction, int): + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_faction_chairpersons where faction_id = %(faction_id)s", { + "faction_id": faction}) + else: + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_faction_chairpersons where faction_name like %(faction_name)s", { + "faction_name": '%' + faction + '%'}) + data = cur_data.fetchall() + except Exception as e: + logger.critical("critical error", e) + return data + + +def get_member_by_govministries(govministry: int | str): + """ + Retrieve distinct member IDs associated with a specified government ministry. + + Parameters: + - govministry (int | str): Either the government ministry ID (if int) or a string representing part or all of the government ministry name. + + Returns: + - list: A list of distinct member IDs associated with the specified government ministry. + + Examples: + ``` + # Example 1: Retrieve individual IDs for members of government ministry with ID 101 + members_ids_1 = get_member_by_govministries(101) + + # Example 2: Retrieve individual IDs for members of government ministry with name 'Health Ministry' + members_ids_2 = get_member_by_govministries('Health Ministry') + """ + try: + with get_db_cursor() as cur_data: + if isinstance(govministry, int): + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_govministries where govministry_id = %(govministry_id)s", { + "govministry_id": govministry}) + else: + cur_data.execute( + "select DISTINCT(mk_individual_id) from members_mk_individual_govministries where govministry_name like %(govministry_name)s", { + "govministry_name": '%' + govministry + '%'}) + data = cur_data.fetchall() except Exception as e: - return e + logger.critical("critical error", e) return data + +def get_member_by_name(name: str): + """ + Retrieve distinct member IDs associated with a specified name. + + Parameters: + - name (str): The name or parts of the name to search for. + + Returns: + - list: A list of distinct member IDs associated with the specified name. + + Examples: + ``` + # Example 1: Retrieve individual IDs for members with the name 'John Doe' + members_ids_1 = get_member_by_name('John Doe') + + # Example 2: Retrieve individual IDs for members with the name 'Jane' + members_ids_2 = get_member_by_name('Jane') + + # Example 3: Retrieve individual IDs for members with the name 'Alice Smith Junior' + members_ids_3 = get_member_by_name('Alice Smith Junior') + ``` + Note: + - The function searches for members based on permutations of the provided name parts. + - It queries the database table 'members_mk_individual' and also considers alternative names stored in the 'altnames' field. + - The results are distinct member IDs associated with the specified name or name parts. + - If no matching member is found, a ValueError is raised. + - If the provided name has too many parts (more than four), a ValueError is raised. + """ + try: + with get_db_cursor(None) as cur: + results = [] + name_parts = name.split() + if len(name_parts) > 4: + return ValueError( + 'too many name parts! Please enter at most four name parts') + name_permutations = [ + ' '.join(p) for p in itertools.permutations(name_parts)] + for name_permutation in name_permutations: + cur.execute( + "select mk_individual_id from members_mk_individual where mk_individual_first_name || ' ' || mk_individual_name like %(name)s", { + "name": '%' + name_permutation + '%'}) + data = cur.fetchall() + results.extend(data) + cur.execute( + "select mk_individual_id from (select mk_individual_id, jsonb_array_elements_text(altnames) altname from members_mk_individual) a where altname like %(name)s", { + "name": '%' + name_permutation + '%'}) + data = cur.fetchall() + results.extend(data) + if len(results) == 0: + return ValueError( + 'There is no member with this name! Please enter another name or consider another spelling') + except Exception as e: + logger.critical("critical error", e) + # Using 'set' to get distinct results and convert back to list + results = list({tuple(d.items()) for d in results}) + return results + + def is_mk_individual_exist(mk_individual_id: int): + """ + Check if a member with the specified mk individual ID exists in the database. + + This function executes a query to check if a member with the provided mk individual ID exists in the + 'members_mk_individual' table of the database. It returns a boolean indicating whether the member exists. + + Usage: + ``` + if is_mk_individual_exist(123): + print("Member exists!") + else: + print("Member does not exist!") + ``` + + Args: + - mk_individual_id (int): The unique individual ID of the member. + + Returns: + bool: True if the member with the specified MK individual ID exists, False otherwise. + + """ try: with get_db_cursor() as cur: cur.execute("""SELECT mk_individual_id - FROM members_mk_individual + FROM members_mk_individual WHERE mk_individual_id=%s""", - (mk_individual_id,)) - is_member_exist=cur.fetchone() - if is_member_exist==None: + (mk_individual_id,)) + is_member_exist = cur.fetchone() + if is_member_exist is None: return False return True except Exception as e: - return e - - - -# Retrieve a list of data results. -# Always streaming result from database in batches of ITTER_SIZE. -# Streaming result from database is available with named cursor -# When using 'psycopg2' library -# The declaration of the named cursor is handled within -# the get_db_cursor() function. -# For example, name = 'oknesset'. -def get_data_list(start_query, limit, offset, order_by, qs): + logger.critical("critical error", e) + + +def is_knesset_term_exist(knesset_term: int): + """ + Check if the specified Knesset term exists in the database. + + This function executes a query to check if a Knesset term exists in the + 'knesset_kns_knessetdates' table of the database. It returns a boolean indicating whether the Knesset term exists. + + Usage: + ``` + if is_knesset_exist(24): + print("Knesset term exists!") + else: + print("Knesset term does not exist!") + ``` + + Args: + - knesset_term (int): Knesset term. + + Returns: + bool: True if the Knesset term exists, False otherwise. + + """ + try: + with get_db_cursor() as cur: + cur.execute("""SELECT "KnessetNum" + FROM knesset_kns_knessetdates + WHERE "KnessetNum"=%s""", + (knesset_term,)) + is_term_exist = cur.fetchone() + if is_term_exist is None: + return False + return True + except Exception as e: + logger.critical("critical error", e) + + +def get_data_list( + start_query: str, + limit: int, + offset: int, + order_by: str, + qs: str): + """ + Retrieve a list of data from the database based on the provided parameters. + + This function creates a query using the provided parameters (limit, offset, order_by, qs), executes the query + on the database, and returns the results. Depending on the size of the data, it either sends a normal + JSONResponse for small data or uses StreamingResponse for large data to enhance performance. + + Usage: + ``` + try: + result = get_data_list( + "SELECT * FROM your_table WHERE condition = %s", + limit=100, + offset=0, + order_by="column1 asc,column2 desc", + qs="param1=value1¶m2=value2" + ) + # Handle the result accordingly + except ValueError as e: + print(f"ValueError: {e}") + ``` + + Args: + - start_query (str): The initial part of the SQL query. + - limit (int): The maximum number of rows to return. + - offset (int): The number of rows to skip before starting to return data. + - order_by (str): A comma-separated string specifying the columns and their sort order (e.g., 'column1 asc,column2 desc'). + - qs (str): A string constructed from key-value pairs joined by '&'. For example, 'param1=value1¶m2=value2'. + + Returns: + Union[responses.JSONResponse, StreamingResponse]: A JSONResponse or StreamingResponse + based on the size of the data. + + Raises: + ValueError: + - If the limit is above 10000 or below 1. + - If the 'order by' parameter is of the wrong format. + """ if limit > 10000: return ValueError("Can't use limit value above 10000") elif limit < 1: return ValueError("Can't use limit value under 1") result = create_query_list(start_query, limit, offset, order_by, qs) - if isinstance(result, Exception): + if isinstance(result, ValueError): return result query = result[0] values = result[1] try: - # For small data size sending normal JSONResponse + # For small data size sending normal JSONResponse # without streaming the result to the client - if(limit<=ITTER_SIZE): + if (limit <= ITTER_SIZE): with get_db_cursor() as cur: cur.execute(query, tuple(values)) data = cur.fetchall() data = json_serialize(data) - return responses.JSONResponse(content=data) + return responses.JSONResponse(content=data) # For large data size sending stream response - # StreamingResponse to the client - else: + # StreamingResponse to the client + else: return responses.StreamingResponse( - streaming_response_iterator(query,values), - media_type="application/json" - ) + streaming_response_iterator(query, values), + media_type="application/json" + ) except Exception as e: - return e + logger.critical("critical error", e) -# Making the generator for streaming the result to the client -def streaming_response_iterator(query,values): - try: - yield b"[" - with get_db_cursor() as cur: - cur.itersize = ITTER_SIZE - cur.execute(query, tuple(values)) - for i, obj in enumerate(cur): - item = encoders.jsonable_encoder(obj) - if i > 0: - yield b"," - yield json.dumps(item).encode() - yield b"]" - except Exception as e: - return e + +def streaming_response_iterator(query: str, values): + """ + Stream data from the database as a JSON array in a FastAPI response. + + This function executes a query on the database and streams the results as a JSON array. It uses FastAPI's + `jsonable_encoder` to convert objects to JSON-serializable format. The data is yielded in chunks to enhance + streaming behavior. + + Usage: + ``` + # Assuming 'query' and 'values' are properly defined + response_iterator = streaming_response_iterator(query, values) + return StreamingResponse(response_iterator, media_type="application/json") + ``` + + Args: + - query (str): The SQL query to execute for streaming data. + - values (Any): The values to be used in the query as parameters. + + Yields: + bytes: Chunks of bytes representing a JSON array. + + """ + try: + yield b"[" + with get_db_cursor() as cur: + cur.itersize = ITTER_SIZE + cur.execute(query, tuple(values)) + for i, obj in enumerate(cur): + item = encoders.jsonable_encoder(obj) + if i > 0: + yield b"," + yield json.dumps(item).encode() + yield b"]" + except Exception as e: + logger.critical("critical error 500", e) def json_serialize(data: List[Dict]): + """ + Serialize a list of dictionaries to JSON-compatible format. + + This function takes a list of dictionaries and serializes it to a format suitable for JSON serialization. + It converts datetime objects to strings in the format "%Y-%m-%dT%H:%M:%S", date objects to strings in + the format "%d/%m/%y", and Decimal objects to floats. Other types remain unchanged. + + Usage: + ``` + data = [{'key1': value1, 'key2': value2}, {'key1': value3, 'key2': value4}] + serialized_data = json_serialize(data) + # Use serialized_data in JSON-related operations + ``` + + Args: + - data (List[Dict]): A list of dictionaries to be serialized. + + Returns: + List[Dict]: A new list of dictionaries with values serialized for JSON compatibility. + + """ def serialize_value(value): if isinstance(value, datetime): return value.strftime("%Y-%m-%dT%H:%M:%S") @@ -218,12 +693,46 @@ def serialize_value(value): ] -# create query that returns data list def create_query_list( - start_query, limit: int = 0, offset: int = 0, + start_query: str, limit: int, offset: int, order_by=None, qs: str | None = None ): - # options: limit, offset, order_by + """ + Create a parameterized SQL query and a list of values based on the provided parameters. + + This function constructs a parameterized SQL query and a list of values for executing the query. It processes + optional parameters such as limit, offset, order_by, and query string (qs) to create a dynamic WHERE clause. + + Usage: + ``` + result = create_query_list( + "SELECT * FROM your_table", + limit=100, + offset=0, + order_by="column1 asc,column2 desc", + qs="param1=value1¶m2=value2" + ) + # Use the result in executing the query + ``` + + Args: + - start_query (str): The initial part of the SQL query. + - limit (int, optional): The maximum number of rows to return. Default is 100. + - offset (int, optional): The number of rows to skip before starting to return data. Default is 0. + - order_by (str, optional): A string specifying the columns and their sort order (e.g., 'column1 asc,column2 desc'). + Default is None. + - qs (str, optional): A string constructed from key-value pairs joined by '&'. For example, 'param1=value1¶m2=value2'. + Default is None. + + Returns: + Union[List, ValueError]: A list containing the constructed query and values, or a ValueError if the order_by + parameter does not match the required format. + + Raises: + ValueError: If the order_by parameter does not match the required format. + + """ + # options: model fields where_optional_args = [] # options: limit, offset, order_by other_optional_args = [] @@ -279,7 +788,7 @@ def create_query_list( val = '[{{"{0}": {1}}}]'.format(object_field, val[1:-1]) values.append(val) where_optional_args.append( - '"{0}" @> %s'.format(object_key) + '"{0}" @> %s'.format(object_key) ) # if here, it's simple data type integer, string or bool else: @@ -292,20 +801,7 @@ def create_query_list( # add arguments to order by clause if order_by is not None: - order_by_clause = '' - pattern = r'^(\w+\s+(?:asc|desc))(?:,\s*\w+\s+(?:asc|desc))*\s*$' - if not re.match(pattern, order_by, re.IGNORECASE): - return ValueError('Must be this format:' - 'column1 asc/desc,column2 asc/desc..') - - for elemt in order_by.split(','): - parts = elemt.split(' ') - column = parts[0] - order_type = parts[1] - order_by_clause += f'"{column}" {order_type},' - # remove last ',' - order_by_clause = order_by_clause[:-1] - other_optional_args.append(f" ORDER BY {order_by_clause}") + other_optional_args.append(f" ORDER BY {order_by}") # add arguments to limit clause if limit > 0: other_optional_args.append(" LIMIT %s") @@ -315,9 +811,14 @@ def create_query_list( other_optional_args.append(" OFFSET %s") values.append(int(offset)) # create the query - query = ( - f"{start_query} WHERE " - + " AND ".join(where_optional_args) - + "".join(other_optional_args) - ) + if (qs): + query = ( + f"{start_query} WHERE " + + " AND ".join(where_optional_args) + + "".join(other_optional_args) + ) + else: + query = ( + f"{start_query}" + "".join(other_optional_args) + ) return [query, values] diff --git a/api/queries.py b/api/queries.py index 0e3f0e7..c047b18 100644 --- a/api/queries.py +++ b/api/queries.py @@ -1,6 +1,6 @@ def get_member_kns_query(id_field): - return f""" - SELECT + return f""" + SELECT f."{id_field}", f."FirstName", f."LastName", @@ -21,7 +21,7 @@ def get_member_kns_query(id_field): LEFT JOIN members_mk_individual_faction_chairpersons ch ON ch."mk_individual_id" = f."mk_individual_id" LEFT JOIN ( - SELECT + SELECT jsonb_array_elements_text(m.member_mk_ids)::integer AS member_mk_id, array_agg(DISTINCT m.knesset) AS knesset_array FROM members_faction_memberships m @@ -38,9 +38,10 @@ def get_member_kns_query(id_field): ORDER BY m."faction_name" DESC LIMIT 1; """ - -def get_minister_query(id_field): - return f""" + + +def get_minister_query(id_field): + return f""" SELECT f."{id_field}", f."FirstName", @@ -93,7 +94,7 @@ def get_minister_query(id_field): def get_members(): - return f""" + return """ SELECT members_mk_individual.mk_individual_id, members_mk_individual.mk_individual_first_name, @@ -110,12 +111,12 @@ def get_members(): COALESCE(json_agg(DISTINCT migm.*), '[]') AS govministries FROM members_mk_individual - LEFT JOIN members_mk_individual_committees mci ON members_mk_individual.mk_individual_id = mci.mk_individual_id AND mci.knesset = %s - LEFT JOIN members_mk_individual_factions mif ON members_mk_individual.mk_individual_id = mif.mk_individual_id AND mif.knesset = %s - LEFT JOIN members_mk_individual_faction_chairpersons mfcp ON members_mk_individual.mk_individual_id = mfcp.mk_individual_id AND mfcp.knesset = %s - LEFT JOIN members_mk_individual_govministries migm ON members_mk_individual.mk_individual_id = migm.mk_individual_id AND migm.knesset = %s + LEFT JOIN members_mk_individual_committees mci ON members_mk_individual.mk_individual_id = mci.mk_individual_id AND mci.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_factions mif ON members_mk_individual.mk_individual_id = mif.mk_individual_id AND mif.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_faction_chairpersons mfcp ON members_mk_individual.mk_individual_id = mfcp.mk_individual_id AND mfcp.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_govministries migm ON members_mk_individual.mk_individual_id = migm.mk_individual_id AND migm.knesset = %(knesset_term)s WHERE - members_mk_individual."IsCurrent" = %s + members_mk_individual."IsCurrent" = %(is_current)s GROUP BY members_mk_individual.mk_individual_id, members_mk_individual.mk_individual_first_name,members_mk_individual.mk_individual_name,members_mk_individual."PersonID",members_mk_individual."GenderID" , @@ -125,18 +126,50 @@ def get_members(): members_mk_individual.altnames; """ -def get_members_presence(mk_individual_id:int): - return f"""select * from members_presence where + +def get_member(): + return """ + SELECT + members_mk_individual.mk_individual_id, + members_mk_individual.mk_individual_first_name, + members_mk_individual.mk_individual_name, + members_mk_individual."PersonID", + members_mk_individual."GenderID", + members_mk_individual."GenderDesc", + members_mk_individual."IsCurrent", + members_mk_individual.mk_individual_email, + members_mk_individual.altnames, + COALESCE(json_agg(DISTINCT mci.*), '[]') AS committee_positions, + COALESCE(json_agg(DISTINCT mif.*), '[]') AS factions, + COALESCE(json_agg(DISTINCT mfcp.*), '[]') AS faction_chairpersons, + COALESCE(json_agg(DISTINCT migm.*), '[]') AS govministries + FROM + members_mk_individual + LEFT JOIN members_mk_individual_committees mci ON members_mk_individual.mk_individual_id = mci.mk_individual_id AND mci.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_factions mif ON members_mk_individual.mk_individual_id = mif.mk_individual_id AND mif.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_faction_chairpersons mfcp ON members_mk_individual.mk_individual_id = mfcp.mk_individual_id AND mfcp.knesset = %(knesset_term)s + LEFT JOIN members_mk_individual_govministries migm ON members_mk_individual.mk_individual_id = migm.mk_individual_id AND migm.knesset = %(knesset_term)s + WHERE + members_mk_individual."mk_individual_id" = %(mk_individual_id)s + GROUP BY + members_mk_individual.mk_individual_id, members_mk_individual.mk_individual_first_name, members_mk_individual.mk_individual_name, members_mk_individual."PersonID", members_mk_individual."GenderID", + members_mk_individual."GenderDesc", members_mk_individual."IsCurrent", members_mk_individual.mk_individual_email, members_mk_individual.altnames; + """ + + +def get_members_presence(mk_individual_id: int): + return f"""select * from members_presence where mk_id = {mk_individual_id} order by date desc """ -def get_members_attended_committee_meetings(mk_individual_id:int): + +def get_members_attended_committee_meetings(mk_individual_id: int): return f"""SELECT - "CommitteeSessionID", "KnessetNum", "TypeID", "TypeDesc", + "CommitteeSessionID", "KnessetNum", "TypeID", "TypeDesc", "CommitteeID", "Location", "SessionUrl", "BroadcastUrl", "StartDate", "FinishDate", "Note", - topics, committee_name, bill_names, bill_types, + topics, committee_name, bill_names, bill_types, related_to_legislation FROM people_committees_meeting_attendees @@ -144,8 +177,10 @@ def get_members_attended_committee_meetings(mk_individual_id:int): attended_mk_individual_ids @> '[{mk_individual_id}]' """ -def get_members_votes(mk_individual_id:int): - return f"""SELECT knesset_num, session_id, sess_item_id, sess_item_dscr, vote_item_id, vote_item_dscr, vote_date, vote_time, is_elctrnc_vote, is_accepted, total_for, total_against, total_abstain, 'pro' AS mk_vote + +def get_members_votes(mk_individual_id: int): + return f"""SELECT * FROM ( + SELECT knesset_num, session_id, sess_item_id, sess_item_dscr, vote_item_id, vote_item_dscr, vote_date, vote_time, is_elctrnc_vote, is_accepted, total_for, total_against, total_abstain, 'pro' AS mk_vote FROM votes_view_vote_rslts_hdr_approved_extra WHERE mk_ids_pro @> '[{mk_individual_id}]' @@ -159,10 +194,12 @@ def get_members_votes(mk_individual_id:int): SELECT knesset_num, session_id, sess_item_id, sess_item_dscr, vote_item_id, vote_item_dscr, vote_date, vote_time, is_elctrnc_vote, is_accepted, total_for, total_against, total_abstain, 'abstain' AS mk_vote FROM votes_view_vote_rslts_hdr_approved_extra - WHERE mk_ids_abstain @> '[{mk_individual_id}]'; - """ + WHERE mk_ids_abstain @> '[{mk_individual_id}]' + ) a + """ -def get_members_bills(mk_individual_id:int): + +def get_members_bills(mk_individual_id: int): return f"""SELECT bkb."BillID", bkb."KnessetNum", @@ -192,5 +229,4 @@ def get_members_bills(mk_individual_id:int): bills_kns_bill bkb ON bkb."BillID" = bkb_init."BillID" WHERE mki.mk_individual_id = {mk_individual_id} - """ - + """ diff --git a/main.py b/main.py index adec5cc..f881bfe 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,7 @@ from fastapi import FastAPI, HTTPException, status, Request, Query from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse -from pydantic import BaseModel -from typing import List, Union ,Optional, List +from typing import List, Optional, Union import models.current_minister as current_minister import models.current_knesset_member as current_knesset_member import models.user_friendly as user_friendly @@ -19,7 +18,6 @@ import errors import api.db as DB - from api import queries as QUERY from datetime import datetime @@ -37,140 +35,350 @@ expose_headers=['*'] ) - -# This endpoint, by default, returns details for current Knesset members only. -# If the 'is_current' parameter is set to false, -# the endpoint returns details for all Knesset members across all time. + @app.get("/members", status_code=200, - description = """By default returns only current knesset - members and all their details for the current knesset - """, - summary="""Get Knesset members and all their details - for some Knesset period""", + description=""" + By default, this endpoint returns information about current Knesset members, + along with their details for the current Knesset. + + You can customize the results using the following parameters: + - `knesset_term` (int, optional): Specify a Knesset number to filter members for a specific term. + - `is_current` (bool, optional): Set to True to retrieve details about current Knesset members, + or False to include details for all Knesset members that are not currently Knesset members. + + Note: If 'factions' for some Knesset member in the output contains null, + it indicates that the Knesset member did not serve during the specified term. + """, + summary="""Retrieve details of Knesset members for + a specified period.""", response_model=List[user_friendly.Member], tags=['user friendly']) -async def get_members_list( - knesset_num:Optional[int] = None, - is_current:Optional[bool] = True, +async def get_friendly_members_list( + knesset_term: Optional[int] = None, + is_current: Optional[bool] = True, ): query = QUERY.get_members() - data = DB.get_members(query,is_current,knesset_num) + data = DB.get_members(query, is_current, knesset_term) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/{mk_individual_id}", status_code=200, + description=""" + By default, this endpoint returns information about current Knesset term. + + You can customize the results using the following parameters: + - `mk_individual_id` (int): Specify the ID of a Knesset member. + - `knesset_term` (int, optional): Specify a Knesset term. + + Note: If 'factions' in the output contains null, it indicates that the Knesset member did not serve during the specified term. + """, + summary="""Retrieve details of some Knesset member for + a specified term.""", + response_model=user_friendly.Member, + tags=['user friendly']) +async def get_friendly_member( + mk_individual_id: int = None, + knesset_term: Optional[int] = None, +): + query = QUERY.get_member() + data = DB.get_member(query, mk_individual_id, knesset_term) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/search/by-committee/{committee}", status_code=200, + description=""" + You can customize the results using the following parameters: + + - `committee` (int | str): Specify a committee ID or name. + """, + summary="""Return mk_individual_id of matching members + filtered by committee ID or name.""", + response_model=List[user_friendly.MkIndividualIDs], + tags=['user friendly']) +async def get_friendly_member_by_committee( + committee: Union[int, str] +): + data = DB.get_member_by_committee(committee) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/search/by-faction/{faction}", status_code=200, + description=""" + You can customize the results using the following parameters: + + - `faction` (int | str): Specify a faction ID or name. + """, + summary="""Return mk_individual_id of matching members factions.""", + response_model=List[user_friendly.MkIndividualIDs], + tags=['user friendly']) +async def get_friendly_member_by_faction( + faction: Union[int, str] +): + data = DB.get_member_by_faction(faction) if isinstance(data, Exception): response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data -# This endpoint, returns info about presence of some Knesset member. -@app.get("/members/{mk_individual_id}/presence", status_code=200, +@app.get("/members/search/by-faction_chairperson/{faction}", + status_code=200, + description=""" + You can customize the results using the following parameters: + + - `faction` (int | str): Specify a faction ID or name. + """, + summary="""Return the mk_individual_id of members who serve as the chairperson of a faction.""", + response_model=List[user_friendly.MkIndividualIDs], + tags=['user friendly']) +async def get_friendly_member_by_faction_chairperson( + faction: Union[int, str] +): + data = DB.get_member_by_faction_chairperson(faction) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/search/by-govministries/{govministry}", + status_code=200, + description=""" + You can customize the results using the following parameters: + + - `govministry` (int | str): Specify a govministry ID or name. + """, + summary="""Return the mk_individual_id of members who are affiliated with a + government ministry.""", + response_model=List[user_friendly.MkIndividualIDs], + tags=['user friendly']) +async def get_friendly_member_by_govministries( + govministry: Union[int, str] +): + data = DB.get_member_by_govministries(govministry) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/search/by-name/{name}", + status_code=200, + description=""" + You can customize the results using the following parameters: + + - `name` (str): Specify a name or part of name of a member. + """, + summary="""Return the mk_individual_id of members who are affiliated with + this name.""", + response_model=List[user_friendly.MkIndividualIDs], + tags=['user friendly']) +async def get_friendly_member_by_name( + name: str +): + data = DB.get_member_by_name(name) + if isinstance(data, Exception): + response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get("/members/{mk_individual_id}/presence", + status_code=200, + description=""" + Retrieve information about the presence of a specific Knesset member. + + You can customize the results using the following parameters: + - `mk_individual_id` (int): The unique identifier of the Knesset member. + """, summary="""Get info about presence of some Knesset member""", response_model=List[user_friendly.MemberPresence], responses={ - 404: errors.NO_DATA_FOUND_ERROR + 404: errors.NO_DATA_FOUND_ERROR }, tags=['user friendly']) -async def get_members_presence_list( - mk_individual_id:int +async def get_friendly_members_presence_list( + limit: int = 100, + offset: int = 0, + mk_individual_id: int = None ): query = QUERY.get_members_presence(mk_individual_id) - data = DB.get_members_info(query,mk_individual_id) + data = DB.get_data_list(query, limit, offset, None, None) if isinstance(data, Exception): response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data -# This endpoint provides information about the attended committee -# meetings of a Knesset member -@app.get("/members/{mk_individual_id}/attended_committee_meetings", +@app.get("/members/{mk_individual_id}/attended_committee_meetings", status_code=200, - response_model=List[user_friendly.MemberAttendedCommitteeMeetings], - summary="""Get info about the attended committee meetings of + description=""" + Retrieve information about the committee meetings attended by a specific Knesset member. + + You can customize the results using the following parameters: + - `mk_individual_id` (int): The unique identifier of the Knesset member. + """, + summary="""Get info about the attended committee meetings of a Knesset member""", + response_model=List[user_friendly.MemberAttendedCommitteeMeetings], responses={ - 404: errors.NO_DATA_FOUND_ERROR + 404: errors.NO_DATA_FOUND_ERROR }, tags=['user friendly']) -async def get_members_attended_committee_meetings_list( - mk_individual_id:int +async def get_friendly_members_attended_committee_meetings_list( + limit: int = 100, + offset: int = 0, + mk_individual_id: int = None ): + order_by = '"StartDate" desc nulls last,"CommitteeSessionID" desc' query = QUERY.get_members_attended_committee_meetings(mk_individual_id) - data = DB.get_members_info(query,mk_individual_id) + data = DB.get_data_list(query, limit, offset, order_by, None) if isinstance(data, Exception): response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data -# This endpoint provides information about -# the votes of a Knesset member -@app.get("/members/{mk_individual_id}/votes", +@app.get("/members/{mk_individual_id}/votes", status_code=200, + description=""" + Retrieve information about the votes cast by a specific Knesset member. + + You can customize the results using the following parameters: + - `mk_individual_id` (int): The unique identifier of the Knesset member. + """, summary="""Get info about the the votes of a Knesset member""", response_model=List[user_friendly.MemberVote], responses={ - 404: errors.NO_DATA_FOUND_ERROR + 404: errors.NO_DATA_FOUND_ERROR }, tags=['user friendly']) -async def get_members_votes_list( - mk_individual_id:int +async def get_friendly_members_votes_list( + limit: int = 100, + offset: int = 0, + mk_individual_id: int = None ): + order_by = 'vote_date desc, vote_time desc, session_id desc, sess_item_id desc' query = QUERY.get_members_votes(mk_individual_id) - data = DB.get_members_info(query,mk_individual_id) + data = DB.get_data_list(query, limit, offset, order_by, None) if isinstance(data, Exception): response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# This endpoint provides information about -# the bills of a Knesset member -@app.get("/members/{mk_individual_id}/bills", + +@app.get("/members/{mk_individual_id}/bills", status_code=200, + description=""" + Retrieve information about the bills associated with a specific Knesset member. + + You can customize the results using the following parameters: + - `mk_individual_id` (int): The unique identifier of the Knesset member. + """, summary="""Get info about the the bills of a Knesset member""", response_model=List[user_friendly.MemberBill], responses={ - 404: errors.NO_DATA_FOUND_ERROR + 404: errors.NO_DATA_FOUND_ERROR }, tags=['user friendly']) -async def get_members_votes_list( - mk_individual_id:int +async def get_friendly_members_bills_list( + limit: int = 100, + offset: int = 0, + mk_individual_id: int = None ): + order_by = '"BillID" desc' query = QUERY.get_members_bills(mk_individual_id) - data = DB.get_members_info(query,mk_individual_id) + data = DB.get_data_list(query, limit, offset, order_by, None) if isinstance(data, Exception): response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list"bills_kns_billunion" table -@app.get("/bills_kns_billunion/list", + +@app.get("/bills_kns_billunion/list", status_code=200, - response_model=List[bills.KnsBillunion], + response_model=List[bills.KnsBillUnion], responses={422: errors.LIMIT_ERROR}, tags=['bills']) async def get_billunion_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, MainBillID: Optional[int] = None, UnionBillID: Optional[int] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list "bills_kns_billunion" table""" query_params = request.query_params.items() + order_by = '"BillUnionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: @@ -178,833 +386,1009 @@ async def get_billunion_list( qs = '&'.join(qs_parts) query = "SELECT * FROM bills_kns_billunion" data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): + if isinstance(data, Exception): response_status = (status.HTTP_422_UNPROCESSABLE_ENTITY - if isinstance(data,ValueError) + if isinstance(data, ValueError) else status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "bills_kns_billunion" table @app.get('/bills_kns_billunion/{BillUnionID}', - response_model=bills.KnsBillunion, + response_model=bills.KnsBillUnion, responses={ - 404: errors.NO_DATA_FOUND_ERROR + 404: errors.NO_DATA_FOUND_ERROR }, tags=['bills'], ) async def get_bill_union(BillUnionID: int): + """Route for single "bills_kns_billunion" table""" data = DB.get_single_data('bills_kns_billunion', 'BillUnionID', BillUnionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list knesset_kns_govministry table -@app.get("/knesset_kns_govministry/list", status_code=200, - response_model=List[knesset.KnsGovministry], +@app.get("/bills_kns_billsplit/list", + status_code=200, + response_model=List[bills.KnsBillSplit], responses={422: errors.LIMIT_ERROR}, - tags=["knesset"]) -async def get_govministry_list( + tags=["bills"]) +async def get_billsplit_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, + MainBillID: Optional[int] = None, + SplitBillID: Optional[int] = None, Name: Optional[str] = None, - IsActive: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_billsplit table""" query_params = request.query_params.items() + order_by = '"BillSplitID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM knesset_kns_govministry" + query = "SELECT * FROM bills_kns_billsplit" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "knesset_kns_govministry" table -@app.get('/knesset_kns_govministry/{GovMinistryID}', - response_model=knesset.KnsGovministry, +@app.get('/bills_kns_billsplit/{BillSplitID}', + response_model=bills.KnsBillSplit, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["knesset"]) -async def get_gov_ministry(GovMinistryID: int): - data = DB.get_single_data('knesset_kns_govministry', - 'GovMinistryID', GovMinistryID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_bill_split(BillSplitID: int): + """Route for "bills_kns_billsplit" table""" + data = DB.get_single_data('bills_kns_billsplit', 'BillSplitID', + BillSplitID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list plenum_kns_documentplenumsession table -@app.get("/plenum_kns_documentplenumsession/list", status_code=200, - response_model=List[plenum.DocumentPlenumSession], +@app.get("/bills_kns_billinitiator/list", + status_code=200, + response_model=List[bills.KnsBillInitiator], responses={422: errors.LIMIT_ERROR}, - tags=["plenum"]) -async def get_documentplenumsession_list( + tags=["bills"]) +async def get_billinitiator_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - PlenumSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, + BillID: Optional[int] = None, + PersonID: Optional[int] = None, + IsInitiator: Optional[bool] = None, + Ordinal: Optional[int] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_billinitiator table""" query_params = request.query_params.items() + order_by = '"BillInitiatorID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM plenum_kns_documentplenumsession" + query = "SELECT * FROM bills_kns_billinitiator" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "plenum_kns_documentplenumsession" table -@app.get('/plenum_kns_documentplenumsession/{DocumentPlenumSessionID}', - response_model=plenum.DocumentPlenumSession, +@app.get('/bills_kns_billinitiator/{BillInitiatorID}', + response_model=bills.KnsBillInitiator, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["plenum"]) -async def get_document_plenum_session(DocumentPlenumSessionID: int): - data = DB.get_single_data('plenum_kns_documentplenumsession', - 'DocumentPlenumSessionID', - DocumentPlenumSessionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_bill_initiator(BillInitiatorID: int): + """Route for single "bills_kns_billinitiator" table""" + data = DB.get_single_data('bills_kns_billinitiator', + 'BillInitiatorID', BillInitiatorID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_mk_individual_faction_chairpersons table -@app.get("/members_mk_individual_faction_chairpersons/list", +@app.get("/bills_kns_billname/list", status_code=200, - response_model=List[members.FactionChairpersons], + response_model=List[bills.KnsBillName], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_faction_chairpersons_list( + tags=["bills"]) +async def get_billname_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - faction_id: Optional[int] = None, - faction_name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - knesset: Optional[int] = None + BillID: Optional[int] = None, + Name: Optional[str] = None, + NameHistoryTypeID: Optional[int] = None, + NameHistoryTypeDesc: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_billname table""" query_params = request.query_params.items() + order_by = '"BillNameID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual_faction_chairpersons" + query = "SELECT * FROM bills_kns_billname" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for "members_mk_individual_faction_chairpersons" table -@app.get('/members_mk_individual_faction_chairpersons/{mk_individual_id}', - response_model=members.FactionChairpersons, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_faction_chairperson(mk_individual_id: int): - data = DB.get_single_data('members_mk_individual_faction_chairpersons', - 'mk_individual_id', mk_individual_id) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_mk_individual_govministries table -@app.get("/members_mk_individual_govministries/list", +@app.get("/bills_kns_documentbill/list", status_code=200, - response_model=List[members.Govministries], + response_model=List[bills.KnsDocumentBill], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_individual_govministries_list( + tags=["bills"]) +async def get_documentbill_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - govministry_id: Optional[int] = None, - govministry_name: Optional[str] = None, - position_id: Optional[int] = None, - position_name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - knesset: Optional[int] = None + BillID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_documentbill table""" query_params = request.query_params.items() + order_by = '"DocumentBillID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual_govministries" + query = "SELECT * FROM bills_kns_documentbill" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_mk_individual_govministries" table -@app.get('/members_mk_individual_govministries/{mk_individual_id}', - response_model=members.Govministries, +@app.get('/bills_kns_documentbill/{DocumentBillID}', + response_model=bills.KnsDocumentBill, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_gov_ministry_member(mk_individual_id: int): - data = DB.get_single_data('members_mk_individual_govministries', - 'mk_individual_id', mk_individual_id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_document_bill(DocumentBillID: int): + """Route for single "bills_kns_documentbill" table""" + data = DB.get_single_data('bills_kns_documentbill', + 'DocumentBillID', DocumentBillID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list bills_kns_billsplit table -@app.get("/bills_kns_billsplit/list", +@app.get("/bills_kns_bill__airflow/list", status_code=200, - response_model=List[bills.KnsBillsplit], + response_model=List[bills.KnsBillAirflow], responses={422: errors.LIMIT_ERROR}, tags=["bills"]) -async def get_billsplit_list( +async def get_bill__airflow_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - MainBillID: Optional[int] = None, - SplitBillID: Optional[int] = None, + KnessetNum: Optional[int] = None, Name: Optional[str] = None, + SubTypeID: Optional[int] = None, + SubTypeDesc: Optional[str] = None, + PrivateNumber: Optional[int] = None, + CommitteeID: Optional[int] = None, + StatusID: Optional[int] = None, + Number: Optional[int] = None, + PostponementReasonID: Optional[int] = None, + PostponementReasonDesc: Optional[str] = None, + PublicationDate: Optional[datetime] = None, + MagazineNumber: Optional[int] = None, + PageNumber: Optional[int] = None, + IsContinuationBill: Optional[bool] = None, + SummaryLaw: Optional[str] = None, + PublicationSeriesID: Optional[int] = None, + PublicationSeriesDesc: Optional[str] = None, + PublicationSeriesFirstCall: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_bill__airflow table""" query_params = request.query_params.items() + order_by = '"BillID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_billsplit" + query = "SELECT * FROM bills_kns_bill__airflow" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "bills_kns_billsplit" table -@app.get('/bills_kns_billsplit/{BillSplitID}', - response_model=bills.KnsBillsplit, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_bill_split(BillSplitID: int): - data = DB.get_single_data('bills_kns_billsplit', 'BillSplitID', - BillSplitID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data +@app.get('/bills_kns_bill__airflow/{BillID}', + response_model=bills.KnsBillAirflow, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_bill_airflow(BillID: int): + """Route for single "bills_kns_bill__airflow" table""" + data = DB.get_single_data('bills_kns_bill__airflow', 'BillID', BillID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data - -# Route for list bills_kns_billinitiator table -@app.get("/bills_kns_billinitiator/list", +@app.get("/bills_kns_billhistoryinitiator/list", status_code=200, - response_model=List[bills.KnsBillInitiator], + response_model=List[bills.KnsBillHistoryInitiator], responses={422: errors.LIMIT_ERROR}, tags=["bills"]) -async def get_billinitiator_list( +async def get_billhistoryinitiator_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, BillID: Optional[int] = None, PersonID: Optional[int] = None, IsInitiator: Optional[bool] = None, - Ordinal: Optional[int] = None, + StartDate: Optional[datetime] = None, + EndDate: Optional[datetime] = None, + ReasonID: Optional[int] = None, + ReasonDesc: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_billhistoryinitiator table""" query_params = request.query_params.items() + order_by = '"BillHistoryInitiatorID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_billinitiator" + query = "SELECT * FROM bills_kns_billhistoryinitiator" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "bills_kns_billinitiator" table -@app.get('/bills_kns_billinitiator/{BillInitiatorID}', - response_model=bills.KnsBillInitiator, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_bill_initiator(BillInitiatorID: int): - data = DB.get_single_data('bills_kns_billinitiator', - 'BillInitiatorID', BillInitiatorID) +@app.get('/bills_kns_billhistoryinitiator/{BillHistoryInitiatorID}', + response_model=bills.KnsBillHistoryInitiator, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_bill_history_initiator(BillHistoryInitiatorID: int): + """Route for single "bills_kns_billhistoryinitiator" table""" + data = DB.get_single_data('bills_kns_billhistoryinitiator', + 'BillHistoryInitiatorID', + BillHistoryInitiatorID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_plenum_session_voters_stats table -@app.get("/people_plenum_session_voters_stats/list", +@app.get("/bills_kns_bill/list", status_code=200, + response_model=List[bills.KnsBill], responses={422: errors.LIMIT_ERROR}, - response_model=List[people.PlenumSessionVotersStats], - tags=["people"]) -async def get_voters_stats_list( + tags=["bills"]) +async def get_bill_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - knesset: Optional[int] = None, - plenum: Optional[int] = None, - assembly: Optional[int] = None, - pagra: Optional[int] = None, - faction_id: Optional[int] = None, - mk_id: Optional[int] = None, - voted_sessions: Optional[int] = None, - total_sessions: Optional[int] = None, - voted_sessions_percent: Optional[int] = None + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + SubTypeID: Optional[int] = None, + SubTypeDesc: Optional[str] = None, + PrivateNumber: Optional[int] = None, + CommitteeID: Optional[int] = None, + StatusID: Optional[int] = None, + Number: Optional[int] = None, + PostponementReasonID: Optional[int] = None, + PostponementReasonDesc: Optional[str] = None, + PublicationDate: Optional[datetime] = None, + MagazineNumber: Optional[int] = None, + PageNumber: Optional[int] = None, + IsContinuationBill: Optional[bool] = None, + SummaryLaw: Optional[str] = None, + PublicationSeriesID: Optional[int] = None, + PublicationSeriesDesc: Optional[str] = None, + PublicationSeriesFirstCall: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list bills_kns_bill table""" query_params = request.query_params.items() + order_by = '"BillID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_plenum_session_voters_stats" + query = "SELECT * FROM bills_kns_bill" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/bills_kns_bill/{BillID}', + response_model=bills.KnsBill, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["bills"]) +async def get_bill(BillID: int): + """Route for single "bills_kns_bill" table""" + data = DB.get_single_data('bills_kns_bill', 'BillID', BillID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list bills_kns_billname table -@app.get("/bills_kns_billname/list", - status_code=200, - response_model=List[bills.KnsBillName], +@app.get("/knesset_kns_govministry/list", status_code=200, + response_model=List[knesset.KnsGovministry], responses={422: errors.LIMIT_ERROR}, - tags=["bills"]) -async def get_billname_list( + tags=["knesset"]) +async def get_govministry_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - BillID: Optional[int] = None, Name: Optional[str] = None, - NameHistoryTypeID: Optional[int] = None, - NameHistoryTypeDesc: Optional[str] = None, + IsActive: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list knesset_kns_govministry table""" query_params = request.query_params.items() + order_by = '"GovMinistryID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_billname" + query = "SELECT * FROM knesset_kns_govministry" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/knesset_kns_govministry/{GovMinistryID}', + response_model=knesset.KnsGovministry, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["knesset"]) +async def get_gov_ministry(GovMinistryID: int): + """Route for single "knesset_kns_govministry" table""" + data = DB.get_single_data('knesset_kns_govministry', + 'GovMinistryID', GovMinistryID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list members_mk_individual_committees table -@app.get("/members_mk_individual_committees/list", +@app.get("/knesset_kns_knessetdates/list", + response_model=List[knesset.KnsKnessetDates], status_code=200, - response_model=List[members.Committees], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_individual_committees_list( + tags=["knesset"]) +async def get_knessetdates_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - mk_individual_id: Optional[int] = None, - committee_id: Optional[int] = None, - committee_name: Optional[str] = None, - position_id: Optional[int] = None, - position_name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - knesset: Optional[int] = None + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + Assembly: Optional[int] = None, + Plenum: Optional[int] = None, + PlenumStart: Optional[str] = None, + PlenumFinish: Optional[str] = None, + IsCurrent: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list knesset_kns_knessetdates table""" query_params = request.query_params.items() + order_by = '"KnessetDateID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual_committees" + query = "SELECT * FROM knesset_kns_knessetdates" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/knesset_kns_knessetdates/{KnessetDateID}', + response_model=knesset.KnsKnessetDates, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["knesset"]) +async def get_knesset_dates(KnessetDateID: int): + """Route for single "knesset_kns_knessetdates" table""" + data = DB.get_single_data('knesset_kns_knessetdates', + 'KnessetDateID', KnessetDateID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list votes_view_vote_rslts_hdr_approved table -@app.get("/votes_view_vote_rslts_hdr_approved/list", - status_code=200, - response_model=List[votes.ViewVoteRsltsHdrApproved], +@app.get("/knesset_kns_status/list", status_code=200, + response_model=List[knesset.KnsStatus], responses={422: errors.LIMIT_ERROR}, - tags=["votes"]) -async def get_vote_rslts_hdr_approved_list( + tags=["knesset"]) +async def get_knesset_status_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - knesset_num: Optional[int] = None, - session_id: Optional[int] = None, - sess_item_nbr: Optional[int] = None, - sess_item_id: Optional[int] = None, - sess_item_dscr: Optional[str] = None, - vote_item_id: Optional[int] = None, - vote_item_dscr: Optional[str] = None, - vote_date: Optional[date] = None, - vote_time: Optional[time] = None, - is_elctrnc_vote: Optional[int] = Query(None, ge=0, le=1), - vote_type: Optional[int] = None, - is_accepted: Optional[int] = None, - total_for: Optional[int] = None, - total_against: Optional[int] = None, - total_abstain: Optional[int] = None, - vote_stat: Optional[int] = None, - session_num: Optional[int] = None, - vote_nbr_in_sess: Optional[int] = None, - reason: Optional[int] = None, - modifier: Optional[str] = None, - remark: Optional[str] = None + Desc: Optional[str] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + OrderTransition: Optional[int] = None, + IsActive: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list knesset_kns_status table""" query_params = request.query_params.items() + order_by = '"StatusID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM votes_view_vote_rslts_hdr_approved" + query = "SELECT * FROM knesset_kns_status" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "votes_view_vote_rslts_hdr_approved" table -@app.get('/votes_view_vote_rslts_hdr_approved/{id}', - response_model=votes.ViewVoteRsltsHdrApproved, +@app.get('/knesset_kns_status/{StatusID}', + response_model=knesset.KnsStatus, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["votes"]) -async def get_voter_result(id: int): - data = DB.get_single_data('votes_view_vote_rslts_hdr_approved', 'id', id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["knesset"]) +async def get_status(StatusID: int): + """Route for single "knesset_kns_status" table""" + data = DB.get_single_data('knesset_kns_status', + 'StatusID', StatusID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_kns_documentcommitteesession_dataservice table -@app.get("/committees_kns_documentcommitteesession_dataservice/list", +@app.get("/knesset_kns_itemtype/list", status_code=200, - response_model=List[committees.KnsDocumentCommitteeSessionDataservice], + response_model=List[knesset.KnsItemtype], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_documentcommitteesession_dataservice_list( + tags=["knesset"]) +async def get_knesset_itemtype_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + Desc: Optional[str] = None, + TableName: Optional[str] = None ): + """Route for list knesset_kns_itemtype table""" query_params = request.query_params.items() + order_by = '"ItemTypeID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_documentcommitteesession_dataservice" + query = "SELECT * FROM knesset_kns_itemtype" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_kns_documentcommitteesession_dataservice" table -@app.get('/committees_kns_documentcommitteesession_dataservice/{DocumentCommitteeSessionID}', - response_model=committees.KnsDocumentCommitteeSessionDataservice, +@app.get('/knesset_kns_itemtype/{ItemTypeID}', + response_model=knesset.KnsItemtype, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_document_committee_session(DocumentCommitteeSessionID: int): - data = DB.get_single_data - ( - 'committees_kns_documentcommitteesession_dataservice', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID - ) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["knesset"]) +async def get_itemtype(ItemTypeID: int): + """Route for single "knesset_kns_itemtype" table""" + data = DB.get_single_data('knesset_kns_itemtype', 'ItemTypeID', ItemTypeID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_kns_jointcommittee table -@app.get("/committees_kns_jointcommittee/list", - status_code=200, - response_model=List[committees.KnsJointCommittee], +@app.get("/plenum_kns_documentplenumsession/list", status_code=200, + response_model=List[plenum.DocumentPlenumSession], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_jointcommittee_list( + tags=["plenum"]) +async def get_documentplenumsession_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeID: Optional[int] = None, - ParticipantCommitteeID: Optional[int] = None, + PlenumSessionID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list plenum_kns_documentplenumsession table""" query_params = request.query_params.items() + order_by = '"DocumentPlenumSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_jointcommittee" + query = "SELECT * FROM plenum_kns_documentplenumsession" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_kns_jointcommittee" table -@app.get('/committees_kns_jointcommittee/{JointCommitteeID}', - response_model=committees.KnsJointCommittee, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_joint_committee(JointCommitteeID: int): - data = DB.get_single_data('committees_kns_jointcommittee', - 'JointCommitteeID', JointCommitteeID) +@app.get('/plenum_kns_documentplenumsession/{DocumentPlenumSessionID}', + response_model=plenum.DocumentPlenumSession, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["plenum"]) +async def get_document_plenum_session(DocumentPlenumSessionID: int): + """Route for single "plenum_kns_documentplenumsession" table""" + data = DB.get_single_data('plenum_kns_documentplenumsession', + 'DocumentPlenumSessionID', + DocumentPlenumSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list votes_vote_rslts_kmmbr_shadow_extra table -@app.get("/votes_vote_rslts_kmmbr_shadow_extra/list", +@app.get("/plenum_kns_plenumsession/list", + response_model=List[plenum.PlenumSession], status_code=200, - response_model=List[votes.VoteRsltsKmmbrShadowExtra], responses={422: errors.LIMIT_ERROR}, - tags=["votes"]) -async def get_vote_rslts_kmmbr_shadow_extra_list( + tags=["plenum"]) +async def get_plenumsession_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - vote_id: Optional[int] = None, - kmmbr_id: Optional[int] = None, - kmmbr_name: Optional[str] = None, - vote_result: Optional[int] = None, - knesset_num: Optional[int] = None, - faction_id: Optional[int] = None, - faction_name: Optional[str] = None, - reason: Optional[int] = None, - modifier: Optional[str] = None, - remark: Optional[str] = None, - result_type_name: Optional[str] = None, - mk_individual_id: Optional[int] = None + PlenumSessionID: Optional[int] = None, + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + IsSpecialMeeting: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list plenum_kns_plenumsession table""" query_params = request.query_params.items() + order_by = '"PlenumSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM votes_vote_rslts_kmmbr_shadow_extra" + query = "SELECT * FROM plenum_kns_plenumsession" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/plenum_kns_plenumsession/{PlenumSessionID}', + response_model=plenum.PlenumSession, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["plenum"]) +async def get_plenum_session(PlenumSessionID: int): + """Route for "plenum_kns_plenumsession" table""" + data = DB.get_single_data('plenum_kns_plenumsession', + 'PlenumSessionID', PlenumSessionID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list plenum_kns_plenumsession table -@app.get("/plenum_kns_plenumsession/list", - response_model=List[plenum.PlenumSession], - status_code=200, +@app.get("/plenum_kns_plmsessionitem/list", status_code=200, + response_model=List[plenum.PlmSessionItem], responses={422: errors.LIMIT_ERROR}, tags=["plenum"]) -async def get_plenumsession_list( +async def get_plmsessionitem_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, + ItemID: Optional[int] = None, PlenumSessionID: Optional[int] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, + ItemTypeID: Optional[int] = None, + ItemTypeDesc: Optional[str] = None, + Ordinal: Optional[int] = None, Name: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - IsSpecialMeeting: Optional[bool] = None, + StatusID: Optional[int] = None, + IsDiscussion: Optional[int] = Query(None, ge=0, le=1), LastUpdatedDate: Optional[datetime] = None ): + """Route for list plenum_kns_plmsessionitem table""" query_params = request.query_params.items() + order_by = '"plmPlenumSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM plenum_kns_plenumsession" + query = "SELECT * FROM plenum_kns_plmsessionitem" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "plenum_kns_plenumsession" table -@app.get('/bills_kns_plenumsession/{PlenumSessionID}', - response_model=plenum.PlenumSession, +@app.get('/plenum_kns_plmsessionitem/{plmPlenumSessionID}', + response_model=plenum.PlmSessionItem, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_plenum_session(PlenumSessionID: int): - data = DB.get_single_data('plenum_kns_plenumsession', - 'PlenumSessionID', PlenumSessionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["plenum"]) +async def get_plmsessionitem(plmPlenumSessionID: int): + """Route for single "plenum_kns_plmsessionitem" table""" + data = DB.get_single_data('plenum_kns_plmsessionitem', + 'plmPlenumSessionID', + plmPlenumSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list bills_kns_documentbill table -@app.get("/bills_kns_documentbill/list", +@app.get("/members_mk_individual_faction_chairpersons/list", status_code=200, - response_model=List[bills.KnsDocumentBill], + response_model=List[members.FactionChairpersons], responses={422: errors.LIMIT_ERROR}, - tags=["bills"]) -async def get_documentbill_list( + tags=["members"]) +async def get_faction_chairpersons_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - BillID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + faction_id: Optional[int] = None, + faction_name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + knesset: Optional[int] = None ): + """Route for list members_mk_individual_faction_chairpersons table""" query_params = request.query_params.items() + order_by = 'mk_individual_id desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_documentbill" + query = "SELECT * FROM members_mk_individual_faction_chairpersons" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "bills_kns_documentbill" table -@app.get('/bills_kns_documentbill/{DocumentBillID}', - response_model=bills.KnsDocumentBill, +@app.get('/members_mk_individual_faction_chairpersons/{mk_individual_id}', + response_model=members.FactionChairpersons, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_document_bill(DocumentBillID: int): - data = DB.get_single_data('bills_kns_documentbill', - 'DocumentBillID', DocumentBillID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_faction_chairperson(mk_individual_id: int): + """Route for "members_mk_individual_faction_chairpersons" table""" + data = DB.get_single_data('members_mk_individual_faction_chairpersons', + 'mk_individual_id', mk_individual_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list bills_kns_bill__airflow table -@app.get("/bills_kns_bill__airflow/list", +@app.get("/members_mk_individual_govministries/list", status_code=200, - response_model=List[bills.KnsBillAirflow], + response_model=List[members.Govministries], responses={422: errors.LIMIT_ERROR}, - tags=["bills"]) -async def get_bill__airflow_list( + tags=["members"]) +async def get_individual_govministries_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - SubTypeID: Optional[int] = None, - SubTypeDesc: Optional[str] = None, - PrivateNumber: Optional[int] = None, - CommitteeID: Optional[int] = None, - StatusID: Optional[int] = None, - Number: Optional[int] = None, - PostponementReasonID: Optional[int] = None, - PostponementReasonDesc: Optional[str] = None, - PublicationDate: Optional[datetime] = None, - MagazineNumber: Optional[int] = None, - PageNumber: Optional[int] = None, - IsContinuationBill: Optional[bool] = None, - SummaryLaw: Optional[str] = None, - PublicationSeriesID: Optional[int] = None, - PublicationSeriesDesc: Optional[str] = None, - PublicationSeriesFirstCall: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + govministry_id: Optional[int] = None, + govministry_name: Optional[str] = None, + position_id: Optional[int] = None, + position_name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + knesset: Optional[int] = None ): + """Route for list members_mk_individual_govministries table""" query_params = request.query_params.items() + order_by = "mk_individual_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_bill__airflow" + query = "SELECT * FROM members_mk_individual_govministries" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "bills_kns_bill__airflow" table -@app.get('/bills_kns_bill__airflow/{BillID}', - response_model=bills.KnsBillAirflow, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_bill_airflow(BillID: int): - data = DB.get_single_data('bills_kns_bill__airflow', 'BillID', BillID) +@app.get('/members_mk_individual_govministries/{mk_individual_id}', + response_model=members.Govministries, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_gov_ministry_member(mk_individual_id: int): + """Route for single "members_mk_individual_govministries" table""" + data = DB.get_single_data('members_mk_individual_govministries', + 'mk_individual_id', mk_individual_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get("/members_mk_individual_committees/list", + status_code=200, + response_model=List[members.Committees], + responses={422: errors.LIMIT_ERROR}, + tags=["members"]) +async def get_individual_committees_list( + request: Request, + limit: int = 100, + offset: int = 0, + mk_individual_id: Optional[int] = None, + committee_id: Optional[int] = None, + committee_name: Optional[str] = None, + position_id: Optional[int] = None, + position_name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + knesset: Optional[int] = None +): + """Route for list members_mk_individual_committees table""" + query_params = request.query_params.items() + order_by = "mk_individual_id desc" + qs_parts = [] + for key, value in query_params: + if key not in ['limit', 'offset', 'order_by']: + qs_parts.append(f"{key}={value}") + qs = '&'.join(qs_parts) + query = "SELECT * FROM members_mk_individual_committees" + data = DB.get_data_list(query, limit, offset, order_by, qs) + if isinstance(data, Exception): + response_status = (status.HTTP_404_NOT_FOUND + if isinstance(data, TypeError) + else status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list members_presence table @app.get("/members_presence/list", status_code=200, response_model=List[members.MembersPresence], @@ -1014,7 +1398,6 @@ async def get_members_presence_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, mk_id: Optional[int] = None, mk_name: Optional[str] = None, date: Optional[date] = None, @@ -1024,7 +1407,9 @@ async def get_members_presence_list( year_week_number: Optional[int] = None, total_attended_hours: Optional[int] = None ): + """Route for list members_presence table""" query_params = request.query_params.items() + order_by = "mk_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: @@ -1033,845 +1418,769 @@ async def get_members_presence_list( query = "SELECT * FROM members_presence" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_kns_committee__airflow table -@app.get("/committees_kns_committee__airflow/list", +@app.get("/members_kns_person__airflow/list", status_code=200, - response_model=List[committees.KnsCommitteeAirflow], + response_model=List[members.PersonAirflow], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_committee__airflow_list( + tags=["members"]) +async def get_person__airflow_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Name: Optional[str] = None, - CategoryID: Optional[int] = None, - CategoryDesc: Optional[str] = None, - KnessetNum: Optional[int] = None, - CommitteeTypeID: Optional[int] = None, - CommitteeTypeDesc: Optional[str] = None, + LastName: Optional[str] = None, + FirstName: Optional[str] = None, + GenderID: Optional[int] = None, + GenderDesc: Optional[str] = None, Email: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - AdditionalTypeID: Optional[int] = None, - AdditionalTypeDesc: Optional[str] = None, - ParentCommitteeID: Optional[int] = None, - CommitteeParentName: Optional[str] = None, IsCurrent: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list members_kns_person__airflow table""" query_params = request.query_params.items() + order_by = '"PersonID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_committee__airflow" + query = "SELECT * FROM members_kns_person__airflow" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_kns_committee__airflow" table -@app.get('/committees_kns_committee__airflow/{CommitteeID}', - response_model=committees.KnsCommitteeAirflow, +@app.get('/members_kns_person__airflow/{PersonID}', + response_model=members.PersonAirflow, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_single_data_airflow(CommitteeID: int): - data = DB.get_single_data('committees_kns_committee__airflow', - 'CommitteeID', CommitteeID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_person_airflow(PersonID: int): + """Route for single "members_kns_person__airflow" table""" + data = DB.get_single_data('members_kns_person__airflow', + 'PersonID', PersonID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_build_build_meetings table -@app.get("/committees_build_build_meetings/list", +@app.get("/members_kns_mksitecode/list", status_code=200, - response_model=List[committees.BuildMeetings], + response_model=List[members.Mksitecode], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_build_meetings_list( + tags=["members"]) +async def get_mksitecode_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - CommitteeID: Optional[int] = None, - Location: Optional[str] = None, - SessionUrl: Optional[str] = None, - BroadcastUrl: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - Note: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - protocol_extension: Optional[str] = None, - text_filename: Optional[str] = None, - parts_filename: Optional[str] = None, - topics: Optional[str] = None, - mks: Optional[str] = None, - invitees_name: Optional[str] = None, - invitees_role: Optional[str] = None, - legal_advisors: Optional[str] = None, - manager: Optional[str] = None, - attended_mk_individual_ids: List[int] = Query( - [], - alias="attended_mk_individual_ids", - example=[736], - list=True - ) + KnsID: Optional[int] = None, + SiteId: Optional[int] = None ): + """Route for list members_kns_mksitecode table""" query_params = request.query_params.items() + order_by = '"MKSiteCode" desc' qs_parts = [] - arrays_number_val = [attended_mk_individual_ids] - arrays_number_names = ["attended_mk_individual_ids"] - arrays_val = [[topics], [mks], [legal_advisors], [manager]] - arrays_name = ["topics", "mks", "legal_advisors", "manager"] - objects_val = [invitees_name, invitees_role] - objects_name = ["invitees_name", "invitees_role"] for key, value in query_params: - if key in arrays_number_names: - elemts = arrays_number_val[arrays_number_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by'] and \ - key not in arrays_name and \ - key not in objects_name: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") - - for name, val in zip(arrays_name, arrays_val): - if val[0]: - qs_parts.append(f"{name}={val}") - for name, val in zip(objects_name, objects_val): - if val: - qs_parts.append(f"{name}=<{val}>") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_build_build_meetings" + query = "SELECT * FROM members_kns_mksitecode" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_build_build_meetings" table -@app.get('/committees_build_build_meetings/{CommitteeSessionID}', - response_model=committees.BuildMeetings, +@app.get('/members_kns_mksitecode/{MKSiteCode}', + response_model=members.Mksitecode, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_build_meeting(CommitteeSessionID: int): - data = DB.get_single_data('committees_build_build_meetings', - 'CommitteeSessionID', CommitteeSessionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_mksitecode(MKSiteCode: int): + """Route for single "members_kns_mksitecode" table""" + data = DB.get_single_data('members_kns_mksitecode', + 'MKSiteCode', MKSiteCode) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_joined_meetings table -@app.get("/people_committees_joined_meetings/list", +@app.get("/members_kns_person/list", status_code=200, - response_model=List[people.CommitteesJoinedMeetings], + response_model=List[members.Person], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_people_committees_joined_meetings_list( + tags=["members"]) +async def get_person_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - CommitteeID: Optional[int] = None, - Location: Optional[str] = None, - SessionUrl: Optional[str] = None, - BroadcastUrl: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - Note: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - text_file_name: Optional[str] = None, - text_file_size: Optional[int] = None, - topics: List[str] = Query( - [], - alias="topics", - example=['שינויים בתקציב לשנת 2003'], - list=True - ) + PersonID: Optional[int] = None, + LastName: Optional[str] = None, + FirstName: Optional[str] = None, + GenderID: Optional[int] = None, + GenderDesc: Optional[str] = None, + Email: Optional[str] = None, + IsCurrent: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list members_kns_person table""" query_params = request.query_params.items() + order_by = '"PersonID" desc' qs_parts = [] - arrays = [topics] - var_names = ["topics"] for key, value in query_params: - if key in var_names: - elemts = arrays[var_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_committees_joined_meetings" + query = "SELECT * FROM members_kns_person" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "people_committees_joined_meetings" table -@app.get('/people_committees_joined_meetings/{CommitteeSessionID}', - response_model=people.CommitteesJoinedMeetings, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["people"]) -async def get_people_committees_joined_meeting(CommitteeSessionID: int): - data = DB.get_single_data('people_committees_joined_meetings', - 'CommitteeSessionID', CommitteeSessionID) +@app.get('/members_kns_person/{PersonID}', + response_model=members.Person, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_person(PersonID: int): + """Route for single "members_kns_person" table""" + data = DB.get_single_data('members_kns_person', 'PersonID', PersonID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list bills_kns_billhistoryinitiator table -@app.get("/bills_kns_billhistoryinitiator/list", +@app.get("/members_mk_individual/list", status_code=200, - response_model=List[bills.KnsBillHistoryInitiator], + response_model=List[members.Individual], responses={422: errors.LIMIT_ERROR}, - tags=["bills"]) -async def get_billhistoryinitiator_list( + tags=["members"]) +async def get_mk_individual_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - BillID: Optional[int] = None, + mk_status_id: Optional[int] = None, + mk_individual_name: Optional[str] = None, + mk_individual_name_eng: Optional[str] = None, + mk_individual_first_name: Optional[str] = None, + mk_individual_first_name_eng: Optional[str] = None, + mk_individual_email: Optional[str] = None, + mk_individual_photo: Optional[str] = None, PersonID: Optional[int] = None, - IsInitiator: Optional[bool] = None, - StartDate: Optional[datetime] = None, - EndDate: Optional[datetime] = None, - ReasonID: Optional[int] = None, - ReasonDesc: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + LastName: Optional[str] = None, + FirstName: Optional[str] = None, + GenderID: Optional[int] = None, + GenderDesc: Optional[str] = None, + Email: Optional[str] = None, + IsCurrent: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None, + altnames: Optional[str] = None, ): + """Route for list members_mk_individual table""" query_params = request.query_params.items() + order_by = "mk_individual_id desc" qs_parts = [] + arrays_val = [[altnames]] + arrays_name = ["altnames"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by'] and \ + key not in arrays_name: qs_parts.append(f"{key}={value}") + for name, val in zip(arrays_name, arrays_val): + if val[0]: + qs_parts.append(f"{name}={val}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_billhistoryinitiator" + query = "SELECT * FROM members_mk_individual" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "bills_kns_billhistoryinitiator" table -@app.get('/bills_kns_billhistoryinitiator/{BillHistoryInitiatorID}', - response_model=bills.KnsBillHistoryInitiator, +@app.get('/members_mk_individual/{mk_individual_id}', + response_model=members.Individual, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_bill_history_initiator(BillHistoryInitiatorID: int): - data = DB.get_single_data('bills_kns_billhistoryinitiator', - 'BillHistoryInitiatorID', - BillHistoryInitiatorID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_individual(mk_individual_id: int): + """Route for single "members_mk_individual" table""" + data = DB.get_single_data('members_mk_individual', + 'mk_individual_id', mk_individual_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_document_background_material_titles table -@app.get("/committees_document_background_material_titles/list", +@app.get("/members_factions/list", status_code=200, - response_model=List[committees.DocumentBackgroundMaterialTitles], + response_model=List[members.Factions], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_document_background_material_titles_list( + tags=["members"]) +async def get_factions_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - CommitteeID: Optional[int] = None, - FilePath: Optional[str] = None, - title: Optional[str] = None + name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + knessets: List[int] = Query([], alias="knessets", example=[], list=True), ): + """Route for list members_factions table""" query_params = request.query_params.items() + order_by = "id desc" qs_parts = [] + arrays_number_val = [knessets] + arrays_number_names = ["knessets"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in arrays_number_names: + elemts = arrays_number_val[arrays_number_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_document_background_material_titles" + query = "SELECT * FROM members_factions" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_document_background_material_titles" table -@app.get( - '/committees_document_background_material_titles/{DocumentCommitteeSessionID}', - response_model=committees.DocumentBackgroundMaterialTitles, - responses={ - 404: errors.NO_DATA_FOUND_ERROR - }, - tags=["committees"] -) -async def get_background_material_title(DocumentCommitteeSessionID: int): - data = DB.get_single_data('committees_document_background_material_titles', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID) +@app.get('/members_factions/{id}', + response_model=members.Factions, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_factions(id: int): + """Route for "members_factions" table""" + data = DB.get_single_data('members_factions', 'id', id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_meeting_attendees table -@app.get("/people_committees_meeting_attendees/list", +@app.get("/members_mk_individual_names/list", status_code=200, - response_model=List[people.CommitteesMeetingAttendees], + response_model=List[members.IndividualNames], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_committees_meeting_attendees_list( + tags=["members"]) +async def get_mk_individual_names_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - CommitteeID: Optional[int] = None, - Location: Optional[str] = None, - SessionUrl: Optional[str] = None, - BroadcastUrl: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - Note: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - download_crc32c: Optional[str] = None, - download_filename: Optional[str] = None, - download_filesize: Optional[int] = None, - parts_crc32c: Optional[str] = None, - parts_filesize: Optional[int] = None, - parts_parsed_filename: Optional[str] = None, - text_crc32c: Optional[str] = None, - text_filesize: Optional[int] = None, - text_parsed_filename: Optional[str] = None, - item_ids: List[int] = Query( - [], - alias="item_ids", - example=[74814], - list=True - ), - item_type_ids: List[int] = Query( - [], - alias="item_type_ids", - example=[11], - list=True - ), - topics: Optional[str] = None, - committee_name: Optional[str] = None, - bill_names: Optional[str] = None, - bill_types: Optional[str] = None, - related_to_legislation: Optional[bool] = None, - mks: Optional[str] = None, - invitees_name: Optional[str] = None, - legal_advisors: Optional[str] = None, - manager: Optional[str] = None, - financial_advisors: Optional[str] = None, - attended_mk_individual_ids: List[int] = Query( - [], - alias="attended_mk_individual_ids", - example=[], - list=True - ) + names: Optional[str] = None, ): + """Route for list members_mk_individual_names table""" query_params = request.query_params.items() + order_by = "mk_individual_id desc" qs_parts = [] - arrays_number_val = [item_ids, item_type_ids, attended_mk_individual_ids] - arrays_number_names = ["item_ids", "item_type_ids", - "attended_mk_individual_ids"] - arrays_val = [[topics], [bill_names], [bill_types], [mks], - [legal_advisors], [manager], [financial_advisors]] - arrays_name = ["topics", "bill_names", "bill_types", "mks", - "legal_advisors", "manager", "financial_advisors"] - objects_val = [invitees_name] - objects_name = ["invitees_name"] + arrays_val = [[names]] + arrays_name = ["names"] for key, value in query_params: - if key in arrays_number_names: - elemts = arrays_number_val[arrays_number_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by'] and \ - key not in arrays_name and \ - key not in objects_name: + if key not in ['limit', 'offset', 'order_by'] and \ + key not in arrays_name: qs_parts.append(f"{key}={value}") - for name, val in zip(arrays_name, arrays_val): if val[0]: qs_parts.append(f"{name}={val}") - for name, val in zip(objects_name, objects_val): - if val: - qs_parts.append(f"{name}=<{val}>") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_committees_meeting_attendees" + query = "SELECT * FROM members_mk_individual_names" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "people_committees_meeting_attendees" table -@app.get('/people_committees_meeting_attendees/{CommitteeSessionID}', - response_model=people.CommitteesMeetingAttendees, +@app.get('/members_mk_individual_names/{mk_individual_id}', + response_model=members.IndividualNames, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["people"]) -async def get_meeting_attendees(CommitteeSessionID: int): - data = DB.get_single_data('people_committees_meeting_attendees', - 'CommitteeSessionID', - CommitteeSessionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_individual_names(mk_individual_id: int): + """Route for single "members_mk_individual_names" table""" + data = DB.get_single_data('members_mk_individual_names', + 'mk_individual_id', + mk_individual_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list knesset_kns_knessetdates table -@app.get("/knesset_kns_knessetdates/list", - response_model=List[knesset.KnsKnessetDates], +@app.get("/members_faction_memberships/list", status_code=200, + response_model=List[members.FactionMemberships], responses={422: errors.LIMIT_ERROR}, - tags=["knesset"]) -async def get_knessetdates_list( + tags=["members"]) +async def get_members_faction_memberships_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - Assembly: Optional[int] = None, - Plenum: Optional[int] = None, - PlenumStart: Optional[str] = None, - PlenumFinish: Optional[str] = None, - IsCurrent: Optional[bool] = None, - LastUpdatedDate: Optional[datetime] = None + faction_id: Optional[int] = None, + faction_name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + member_mk_ids: List[int] = Query( + [], alias="member_mk_ids", + example=[], + list=True + ), + knesset: Optional[int] = None ): + """Route for list members_faction_memberships table""" query_params = request.query_params.items() + order_by = "faction_id desc" qs_parts = [] + arrays_number_val = [member_mk_ids] + arrays_number_names = ["member_mk_ids"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in arrays_number_names: + elemts = arrays_number_val[arrays_number_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM knesset_kns_knessetdates" + query = "SELECT * FROM members_faction_memberships" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "knesset_kns_knessetdates" table -@app.get('/knesset_kns_knessetdates/{KnessetDateID}', - response_model=knesset.KnsKnessetDates, +@app.get('/members_faction_memberships/{faction_id}', + response_model=members.FactionMemberships, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["knesset"]) -async def get_knesset_dates(KnessetDateID: int): - data = DB.get_single_data('knesset_kns_knessetdates', - 'KnessetDateID', KnessetDateID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_faction_memberships(faction_id: int): + """Route for single "members_faction_memberships" table""" + data = DB.get_single_data('members_faction_memberships', + 'faction_id', faction_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list votes_view_vote_mk_individual table -@app.get("/votes_view_vote_mk_individual/list", +@app.get("/members_kns_persontoposition/list", status_code=200, - response_model=List[votes.ViewVoteMkIndividual], + response_model=List[members.PersonToPosition], responses={422: errors.LIMIT_ERROR}, - tags=["votes"]) -async def get_vote_mk_individual_list( + tags=["members"]) +async def get_person_to_position_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - mk_individual_id: Optional[int] = None, - mk_individual_name: Optional[str] = None, - mk_individual_name_eng: Optional[str] = None, - mk_individual_first_name: Optional[str] = None, - mk_individual_first_name_eng: Optional[str] = None + PersonID: Optional[int] = None, + PositionID: Optional[int] = None, + KnessetNum: Optional[int] = None, + GovMinistryID: Optional[int] = None, + GovMinistryName: Optional[str] = None, + DutyDesc: Optional[str] = None, + FactionID: Optional[int] = None, + FactionName: Optional[str] = None, + GovernmentNum: Optional[int] = None, + CommitteeID: Optional[int] = None, + CommitteeName: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + IsCurrent: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list members_kns_persontoposition table""" query_params = request.query_params.items() + order_by = '"PersonToPositionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM votes_view_vote_mk_individual" + query = "SELECT * FROM members_kns_persontoposition" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "votes_view_vote_mk_individual" table -@app.get('/votes_view_vote_mk_individual/{vip_id}', - response_model=votes.ViewVoteMkIndividual, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["votes"]) -async def get_vote_mk_individual(vip_id: int): - data = DB.get_single_data('votes_view_vote_mk_individual', - 'vip_id', vip_id) +@app.get('/members_kns_persontoposition/{PersonToPositionID}', + response_model=members.PersonToPosition, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["members"]) +async def get_persontoposition(PersonToPositionID: int): + """Route for single "members_kns_persontoposition" table""" + data = DB.get_single_data('members_kns_persontoposition', + 'PersonToPositionID', + PersonToPositionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list bills_kns_bill table -@app.get("/bills_kns_bill/list", +@app.get("/members_mk_individual_factions/list", status_code=200, - response_model=List[bills.KnsBill], + response_model=List[members.IndividualFactions], responses={422: errors.LIMIT_ERROR}, - tags=["bills"]) -async def get_bill_list( + tags=["members"]) +async def get_mk_individual_factions_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - SubTypeID: Optional[int] = None, - SubTypeDesc: Optional[str] = None, - PrivateNumber: Optional[int] = None, - CommitteeID: Optional[int] = None, - StatusID: Optional[int] = None, - Number: Optional[int] = None, - PostponementReasonID: Optional[int] = None, - PostponementReasonDesc: Optional[str] = None, - PublicationDate: Optional[datetime] = None, - MagazineNumber: Optional[int] = None, - PageNumber: Optional[int] = None, - IsContinuationBill: Optional[bool] = None, - SummaryLaw: Optional[str] = None, - PublicationSeriesID: Optional[int] = None, - PublicationSeriesDesc: Optional[str] = None, - PublicationSeriesFirstCall: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + mk_individual_id: Optional[int] = None, + faction_id: Optional[int] = None, + faction_name: Optional[str] = None, + start_date: Optional[date] = None, + finish_date: Optional[date] = None, + knesset: Optional[int] = None ): + """Route for list members_mk_individual_factions table""" query_params = request.query_params.items() + order_by = "mk_individual_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM bills_kns_bill" + query = "SELECT * FROM members_mk_individual_factions" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "bills_kns_bill" table -@app.get('/bills_kns_bill/{BillID}', - response_model=bills.KnsBill, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["bills"]) -async def get_bill(BillID: int): - data = DB.get_single_data('bills_kns_bill', 'BillID', BillID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_kns_person__airflow table -@app.get("/members_kns_person__airflow/list", +@app.get("/members_kns_position/list", status_code=200, - response_model=List[members.PersonAirflow], + response_model=List[members.Position], responses={422: errors.LIMIT_ERROR}, tags=["members"]) -async def get_person__airflow_list( +async def get_position_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - LastName: Optional[str] = None, - FirstName: Optional[str] = None, + Description: Optional[str] = None, GenderID: Optional[int] = None, GenderDesc: Optional[str] = None, - Email: Optional[str] = None, - IsCurrent: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list members_kns_position table""" query_params = request.query_params.items() + order_by = '"PositionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_kns_person__airflow" + query = "SELECT * FROM members_kns_position" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_kns_person__airflow" table -@app.get('/members_kns_person__airflow/{PersonID}', - response_model=members.PersonAirflow, +@app.get('/members_kns_position/{PositionID}', + response_model=members.Position, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=["members"]) -async def get_person_airflow(PersonID: int): - data = DB.get_single_data('members_kns_person__airflow', - 'PersonID', PersonID) +async def get_position(PositionID: int): + """Route for single "members_kns_position" table""" + data = DB.get_single_data('members_kns_position', + 'PositionID', PositionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for committees_joined_meetings table -@app.get("/committees_joined_meetings/list", +@app.get("/votes_view_vote_rslts_hdr_approved/list", status_code=200, - response_model=List[committees.JoinedMeetings], + response_model=List[votes.ViewVoteRsltsHdrApproved], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_joined_meetings_list( + tags=["votes"]) +async def get_vote_rslts_hdr_approved_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - CommitteeID: Optional[int] = None, - Location: Optional[str] = None, - SessionUrl: Optional[str] = None, - BroadcastUrl: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - Note: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - protocol_extension: Optional[str] = None, - text_filename: Optional[str] = None, - parts_filename: Optional[str] = None, - topics: Optional[str] = None + knesset_num: Optional[int] = None, + session_id: Optional[int] = None, + sess_item_nbr: Optional[int] = None, + sess_item_id: Optional[int] = None, + sess_item_dscr: Optional[str] = None, + vote_item_id: Optional[int] = None, + vote_item_dscr: Optional[str] = None, + vote_date: Optional[date] = None, + vote_time: Optional[time] = None, + is_elctrnc_vote: Optional[int] = Query(None, ge=0, le=1), + vote_type: Optional[int] = None, + is_accepted: Optional[int] = None, + total_for: Optional[int] = None, + total_against: Optional[int] = None, + total_abstain: Optional[int] = None, + vote_stat: Optional[int] = None, + session_num: Optional[int] = None, + vote_nbr_in_sess: Optional[int] = None, + reason: Optional[int] = None, + modifier: Optional[str] = None, + remark: Optional[str] = None ): + """Route for list votes_view_vote_rslts_hdr_approved table""" query_params = request.query_params.items() + order_by = "id desc" qs_parts = [] - arrays = [[topics]] - var_names = ["topics"] for key, value in query_params: - if key in var_names: - elemts = arrays[var_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_joined_meetings" + query = "SELECT * FROM votes_view_vote_rslts_hdr_approved" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_joined_meetings" table -@app.get('/committees_joined_meetings/{CommitteeSessionID}', - response_model=committees.JoinedMeetings, +@app.get('/votes_view_vote_rslts_hdr_approved/{id}', + response_model=votes.ViewVoteRsltsHdrApproved, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_joined_meeting(CommitteeSessionID: int): - data = DB.get_single_data('committees_joined_meetings', - 'CommitteeSessionID', - CommitteeSessionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["votes"]) +async def get_voter_result(id: int): + """Route for single "votes_view_vote_rslts_hdr_approved" table""" + data = DB.get_single_data('votes_view_vote_rslts_hdr_approved', 'id', id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_mk_party_discipline_stats table -@app.get("/people_mk_party_discipline_stats/list", +@app.get("/votes_view_vote_rslts_hdr_approved_extra/list", status_code=200, - response_model=List[people.PartyDisciplineStats], + response_model=List[votes.ViewVoteRsltsHdrApprovedExtra], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_mk_party_discipline_stats_list( + tags=["votes"]) +async def get_vote_rslts_hdr_approved_extra_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, + knesset_num: Optional[int] = None, + session_id: Optional[int] = None, + sess_item_nbr: Optional[int] = None, + sess_item_id: Optional[int] = None, + sess_item_dscr: Optional[str] = None, + vote_item_id: Optional[int] = None, + vote_item_dscr: Optional[str] = None, + vote_date: Optional[date] = None, + vote_time: Optional[time] = None, + is_elctrnc_vote: Optional[int] = None, + vote_type: Optional[int] = None, + is_accepted: Optional[int] = None, + total_for: Optional[int] = None, + total_against: Optional[int] = None, + total_abstain: Optional[int] = None, + vote_stat: Optional[str] = None, + session_num: Optional[int] = None, + vote_nbr_in_sess: Optional[int] = None, + reason: Optional[int] = None, + modifier: Optional[str] = None, + remark: Optional[str] = None, + mk_ids_pro: List[int] = Query([], example=[], list=True), + mk_ids_against: List[int] = Query([], example=[], list=True), + mk_ids_abstain: List[int] = Query([], example=[], list=True), knesset: Optional[int] = None, plenum: Optional[int] = None, assembly: Optional[int] = None, - pagra: Optional[int] = None, - faction_id: Optional[int] = None, - mk_id: Optional[int] = None, - undisciplined_votes: Optional[int] = None, - disciplined_votes: Optional[int] = None, - total_votes: Optional[int] = None, - undisciplined_votes_percent: Optional[int] = None, - disciplined_votes_percent: Optional[int] = None -): - query_params = request.query_params.items() - qs_parts = [] - for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: - qs_parts.append(f"{key}={value}") - qs = '&'.join(qs_parts) - query = "SELECT * FROM people_mk_party_discipline_stats" - data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND - if isinstance(data, TypeError) - else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for list knesset_kns_status table -@app.get("/knesset_kns_status/list",status_code=200, - response_model=List[knesset.KnsStatus], - responses={422: errors.LIMIT_ERROR}, - tags=["knesset"]) -async def get_knesset_status_list( - request: Request, - limit: int = 100, - offset: int = 0, - order_by: Optional[str] = None, - Desc: Optional[str] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - OrderTransition: Optional[int] = None, - IsActive: Optional[bool] = None, - LastUpdatedDate: Optional[datetime] = None + pagra: Optional[bool] = None ): + """Route for list votes_view_vote_rslts_hdr_approved_extra table""" query_params = request.query_params.items() + order_by = "id desc" qs_parts = [] + arrays = [mk_ids_pro, mk_ids_against, mk_ids_abstain] + var_names = ["mk_ids_pro", "mk_ids_against", "mk_ids_abstain"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in var_names: + elemts = arrays[var_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM knesset_kns_status" + query = "SELECT * FROM votes_view_vote_rslts_hdr_approved_extra" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "knesset_kns_status" table -@app.get('/knesset_kns_status/{StatusID}', - response_model=knesset.KnsStatus, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["knesset"]) -async def get_status(StatusID: int): - data = DB.get_single_data('knesset_kns_status', - 'StatusID', StatusID) +@app.get('/votes_view_vote_rslts_hdr_approved_extra/{id}', + response_model=votes.ViewVoteRsltsHdrApprovedExtra, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["votes"]) +async def get_vote_rslts_hdr_approved_extra(id: int): + """Route for "votes_view_vote_rslts_hdr_approved_extra" table""" + data = DB.get_single_data('votes_view_vote_rslts_hdr_approved_extra', + 'id', id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list votes_vote_rslts_kmmbr_shadow table @app.get("/votes_vote_rslts_kmmbr_shadow/list", status_code=200, response_model=List[votes.VoteRsltsKmmbrShadow], @@ -1881,7 +2190,6 @@ async def get_vote_rslts_kmmbr_shadow_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, vote_id: Optional[int] = None, kmmbr_id: Optional[int] = None, kmmbr_name: Optional[str] = None, @@ -1893,7 +2201,9 @@ async def get_vote_rslts_kmmbr_shadow_list( modifier: Optional[str] = None, remark: Optional[str] = None ): + """Route for list votes_vote_rslts_kmmbr_shadow table""" query_params = request.query_params.items() + order_by = "vote_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: @@ -1902,153 +2212,180 @@ async def get_vote_rslts_kmmbr_shadow_list( query = "SELECT * FROM votes_vote_rslts_kmmbr_shadow" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_meeting_attendees_mks_full_stats table -@app.get("/people_committees_meeting_attendees_mks_full_stats/list", +@app.get("/votes_vote_rslts_kmmbr_shadow_extra/list", status_code=200, - response_model=List[people.CommitteesMeetingAttendeesMksFullStats], + response_model=List[votes.VoteRsltsKmmbrShadowExtra], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_attendees_mks_full_stats_list( + tags=["votes"]) +async def get_vote_rslts_kmmbr_shadow_extra_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - knesset: Optional[int] = None, - plenum: Optional[int] = None, - assembly: Optional[int] = None, - pagra: Optional[int] = None, - committee_id: Optional[int] = None, + vote_id: Optional[int] = None, + kmmbr_id: Optional[int] = None, + kmmbr_name: Optional[str] = None, + vote_result: Optional[int] = None, + knesset_num: Optional[int] = None, faction_id: Optional[int] = None, - mk_id: Optional[int] = None, - attended_meetings: Optional[int] = None, - protocol_meetings: Optional[int] = None, - open_meetings: Optional[int] = None, - attended_meetings_percent: Optional[int] = None, - attended_meetings_relative_percent: Optional[int] = None + faction_name: Optional[str] = None, + reason: Optional[int] = None, + modifier: Optional[str] = None, + remark: Optional[str] = None, + result_type_name: Optional[str] = None, + mk_individual_id: Optional[int] = None ): + """Route for list votes_vote_rslts_kmmbr_shadow_extra table""" query_params = request.query_params.items() + order_by = "vote_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_committees_meeting_attendees_mks_full_stats" + query = "SELECT * FROM votes_vote_rslts_kmmbr_shadow_extra" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_meeting_speaker_stats table -@app.get("/people_committees_meeting_speaker_stats/list", +@app.get("/votes_view_vote_mk_individual/list", status_code=200, - response_model=List[people.CommitteesMeetingSpeakerStats], + response_model=List[votes.ViewVoteMkIndividual], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_meeting_speaker_stats_list( + tags=["votes"]) +async def get_vote_mk_individual_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - parts_crc32c: Optional[str] = None, - part_index: Optional[int] = None, - header: Optional[str] = None, - body_length: Optional[int] = None, - body_num_words: Optional[int] = None, - part_categories: Optional[str] = None, - name_role: Optional[str] = None, mk_individual_id: Optional[int] = None, - mk_individual_faction: Optional[str] = None + mk_individual_name: Optional[str] = None, + mk_individual_name_eng: Optional[str] = None, + mk_individual_first_name: Optional[str] = None, + mk_individual_first_name_eng: Optional[str] = None ): + """Route for list votes_view_vote_mk_individual table""" query_params = request.query_params.items() + order_by = "vip_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_committees_meeting_speaker_stats" + query = "SELECT * FROM votes_view_vote_mk_individual" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/votes_view_vote_mk_individual/{vip_id}', + response_model=votes.ViewVoteMkIndividual, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["votes"]) +async def get_vote_mk_individual(vip_id: int): + """Route for single "votes_view_vote_mk_individual" table""" + data = DB.get_single_data('votes_view_vote_mk_individual', + 'vip_id', vip_id) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list committees_kns_cmtsitecode table -@app.get("/committees_kns_cmtsitecode/list", +@app.get("/votes_vote_result_type/list", status_code=200, - response_model=List[committees.KnsCmtSitecode], + response_model=List[votes.VoteResultType], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_cmtsitecode_list( + tags=["votes"]) +async def get_vote_result_type_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnsID: Optional[int] = None, - SiteId: Optional[int] = None + result_type_name: Optional[str] = None ): + """Route for votes_vote_result_type table""" query_params = request.query_params.items() + order_by = "result_type_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_cmtsitecode" + query = "SELECT * FROM votes_vote_result_type" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_kns_cmtsitecode" table -@app.get('/committees_kns_cmtsitecode/{CmtSiteCode}', - response_model=committees.KnsCmtSitecode, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_cmt_site_code(CmtSiteCode: int): - data = DB.get_single_data('committees_kns_cmtsitecode', - 'CmtSiteCode', CmtSiteCode) +@app.get('/votes_vote_result_type/{result_type_id}', + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["votes"]) +async def get_vote_result_type(result_type_id: int): + """Route for single "votes_vote_result_type" table""" + data = DB.get_single_data('votes_vote_result_type', + 'result_type_id', result_type_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list laws_kns_document_law table -@app.get("/laws_kns_document_law/list", status_code=200, - response_model=List[laws.DocumentLaw], +@app.get("/committees_kns_documentcommitteesession_dataservice/list", + status_code=200, + response_model=List[committees.KnsDocumentCommitteeSessionDataservice], responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_document_law_list( + tags=["committees"]) +async def get_documentcommitteesession_dataservice_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - LawID: Optional[int] = None, + CommitteeSessionID: Optional[int] = None, GroupTypeID: Optional[int] = None, GroupTypeDesc: Optional[str] = None, ApplicationID: Optional[int] = None, @@ -2056,425 +2393,644 @@ async def get_document_law_list( FilePath: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list committees_kns_documentcommitteesession_dataservice table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_document_law" + query = "SELECT * FROM committees_kns_documentcommitteesession_dataservice" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "laws_kns_document_law" table -@app.get('/laws_kns_document_law/{DocumentLawID}', - response_model=laws.DocumentLaw, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_document_law(DocumentLawID: int): - data = DB.get_single_data('laws_kns_document_law', - 'DocumentLawID', DocumentLawID) +@app.get( + '/committees_kns_documentcommitteesession_dataservice/{DocumentCommitteeSessionID}', + response_model=committees.KnsDocumentCommitteeSessionDataservice, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_document_committee_session(DocumentCommitteeSessionID: int): + """Route for single "committees_kns_documentcommitteesession_dataservice" table""" + data = DB.get_single_data + ( + 'committees_kns_documentcommitteesession_dataservice', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID + ) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_meeting_protocols_parts table -@app.get("/committees_meeting_protocols_parts/list", +@app.get("/committees_kns_jointcommittee/list", status_code=200, - response_model=List[committees.MeetingProtocolsParts], + response_model=List[committees.KnsJointCommittee], responses={422: errors.LIMIT_ERROR}, tags=["committees"]) -async def get_meeting_protocols_parts_list( +async def get_jointcommittee_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - KnessetNum: Optional[int] = None, - protocol_extension: Optional[str] = None, - parsed_filename: Optional[str] = None, - filesize: Optional[int] = None, - crc32c: Optional[str] = None, - error: Optional[str] = None + CommitteeID: Optional[int] = None, + ParticipantCommitteeID: Optional[int] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list committees_kns_jointcommittee table""" query_params = request.query_params.items() + order_by = '"JointCommitteeID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_meeting_protocols_parts" + query = "SELECT * FROM committees_kns_jointcommittee" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_meeting_protocols_parts" table -@app.get('/committees_meeting_protocols_parts/{DocumentCommitteeSessionID}', - response_model=committees.MeetingProtocolsParts, +@app.get('/committees_kns_jointcommittee/{JointCommitteeID}', + response_model=committees.KnsJointCommittee, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=["committees"]) -async def get_meeting_protocols_parts(DocumentCommitteeSessionID: int): - data = DB.get_single_data('committees_meeting_protocols_parts', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID) +async def get_joint_committee(JointCommitteeID: int): + """Route for single "committees_kns_jointcommittee" table""" + data = DB.get_single_data('committees_kns_jointcommittee', + 'JointCommitteeID', JointCommitteeID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list votes_view_vote_rslts_hdr_approved_extra table -@app.get("/votes_view_vote_rslts_hdr_approved_extra/list", +@app.get("/committees_kns_committee__airflow/list", status_code=200, - response_model=List[votes.ViewVoteRsltsHdrApprovedExtra], + response_model=List[committees.KnsCommitteeAirflow], responses={422: errors.LIMIT_ERROR}, - tags=["votes"]) -async def get_vote_rslts_hdr_approved_extra_list( + tags=["committees"]) +async def get_committee__airflow_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - knesset_num: Optional[int] = None, - session_id: Optional[int] = None, - sess_item_nbr: Optional[int] = None, - sess_item_id: Optional[int] = None, - sess_item_dscr: Optional[str] = None, - vote_item_id: Optional[int] = None, - vote_item_dscr: Optional[str] = None, - vote_date: Optional[date] = None, - vote_time: Optional[time] = None, - is_elctrnc_vote: Optional[int] = None, - vote_type: Optional[int] = None, - is_accepted: Optional[int] = None, - total_for: Optional[int] = None, - total_against: Optional[int] = None, - total_abstain: Optional[int] = None, - vote_stat: Optional[str] = None, - session_num: Optional[int] = None, - vote_nbr_in_sess: Optional[int] = None, - reason: Optional[int] = None, - modifier: Optional[str] = None, - remark: Optional[str] = None, - mk_ids_pro: List[int] = Query([], example=[], list=True), - mk_ids_against: List[int] = Query([], example=[], list=True), - mk_ids_abstain: List[int] = Query([], example=[], list=True), - knesset: Optional[int] = None, - plenum: Optional[int] = None, - assembly: Optional[int] = None, - pagra: Optional[bool] = None + Name: Optional[str] = None, + CategoryID: Optional[int] = None, + CategoryDesc: Optional[str] = None, + KnessetNum: Optional[int] = None, + CommitteeTypeID: Optional[int] = None, + CommitteeTypeDesc: Optional[str] = None, + Email: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + AdditionalTypeID: Optional[int] = None, + AdditionalTypeDesc: Optional[str] = None, + ParentCommitteeID: Optional[int] = None, + CommitteeParentName: Optional[str] = None, + IsCurrent: Optional[bool] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list committees_kns_committee__airflow table""" query_params = request.query_params.items() + order_by = '"CommitteeID" desc' qs_parts = [] - arrays = [mk_ids_pro, mk_ids_against, mk_ids_abstain] - var_names = ["mk_ids_pro", "mk_ids_against", "mk_ids_abstain"] for key, value in query_params: - if key in var_names: - elemts = arrays[var_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM votes_view_vote_rslts_hdr_approved_extra" + query = "SELECT * FROM committees_kns_committee__airflow" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "votes_view_vote_rslts_hdr_approved_extra" table -@app.get('/votes_view_vote_rslts_hdr_approved_extra/{id}', - response_model=votes.ViewVoteRsltsHdrApprovedExtra, +@app.get('/committees_kns_committee__airflow/{CommitteeID}', + response_model=committees.KnsCommitteeAirflow, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["votes"]) -async def get_vote_rslts_hdr_approved_extra(id: int): - data = DB.get_single_data('votes_view_vote_rslts_hdr_approved_extra', - 'id', id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_single_data_airflow(CommitteeID: int): + """Route for single "committees_kns_committee__airflow" table""" + data = DB.get_single_data('committees_kns_committee__airflow', + 'CommitteeID', CommitteeID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_build_rendered_meetings_stats table -@app.get("/committees_build_rendered_meetings_stats/list", +@app.get("/committees_build_build_meetings/list", status_code=200, - response_model=List[committees.BuildRenderedMeetingsStats], + response_model=List[committees.BuildMeetings], responses={422: errors.LIMIT_ERROR}, tags=["committees"]) -async def get_build_rendered_meetings_stats_list( +async def get_build_meetings_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - num_speech_parts: Optional[int] = None + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + CommitteeID: Optional[int] = None, + Location: Optional[str] = None, + SessionUrl: Optional[str] = None, + BroadcastUrl: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + Note: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + protocol_extension: Optional[str] = None, + text_filename: Optional[str] = None, + parts_filename: Optional[str] = None, + topics: Optional[str] = None, + mks: Optional[str] = None, + invitees_name: Optional[str] = None, + invitees_role: Optional[str] = None, + legal_advisors: Optional[str] = None, + manager: Optional[str] = None, + attended_mk_individual_ids: List[int] = Query( + [], + alias="attended_mk_individual_ids", + example=[736], + list=True + ) ): + """Route for list committees_build_build_meetings table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] + arrays_number_val = [attended_mk_individual_ids] + arrays_number_names = ["attended_mk_individual_ids"] + arrays_val = [[topics], [mks], [legal_advisors], [manager]] + arrays_name = ["topics", "mks", "legal_advisors", "manager"] + objects_val = [invitees_name, invitees_role] + objects_name = ["invitees_name", "invitees_role"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in arrays_number_names: + elemts = arrays_number_val[arrays_number_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by'] and \ + key not in arrays_name and \ + key not in objects_name: qs_parts.append(f"{key}={value}") + + for name, val in zip(arrays_name, arrays_val): + if val[0]: + qs_parts.append(f"{name}={val}") + for name, val in zip(objects_name, objects_val): + if val: + qs_parts.append(f"{name}=<{val}>") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_build_rendered_meetings_stats" + query = "SELECT * FROM committees_build_build_meetings" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_build_rendered_meetings_stats" table -@app.get('/committees_build_rendered_meetings_stats/{CommitteeSessionID}', - response_model=committees.BuildRenderedMeetingsStats, +@app.get('/committees_build_build_meetings/{CommitteeSessionID}', + response_model=committees.BuildMeetings, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=["committees"]) -async def get_rendered_meetings_stats(CommitteeSessionID: int): - data = DB.get_single_data('committees_build_rendered_meetings_stats', - 'CommitteeSessionID', - CommitteeSessionID) +async def get_build_meeting(CommitteeSessionID: int): + """Route for single "committees_build_build_meetings" table""" + data = DB.get_single_data('committees_build_build_meetings', + 'CommitteeSessionID', CommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list plenum_kns_plmsessionitem table -@app.get("/plenum_kns_plmsessionitem/list", status_code=200, - response_model=List[plenum.PlmSessionItem], +@app.get("/committees_document_background_material_titles/list", + status_code=200, + response_model=List[committees.DocumentBackgroundMaterialTitles], responses={422: errors.LIMIT_ERROR}, - tags=["plenum"]) -async def get_plmsessionitem_list( + tags=["committees"]) +async def get_document_background_material_titles_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - ItemID: Optional[int] = None, - PlenumSessionID: Optional[int] = None, - ItemTypeID: Optional[int] = None, - ItemTypeDesc: Optional[str] = None, - Ordinal: Optional[int] = None, - Name: Optional[str] = None, - StatusID: Optional[int] = None, - IsDiscussion: Optional[int] = Query(None, ge=0, le=1), - LastUpdatedDate: Optional[datetime] = None + CommitteeSessionID: Optional[int] = None, + CommitteeID: Optional[int] = None, + FilePath: Optional[str] = None, + title: Optional[str] = None ): + """Route for list committees_document_background_material_titles table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM plenum_kns_plmsessionitem" + query = "SELECT * FROM committees_document_background_material_titles" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "plenum_kns_plmsessionitem" table -@app.get('/plenum_kns_plmsessionitem/{plmPlenumSessionID}', - response_model=plenum.PlmSessionItem, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["plenum"]) -async def get_plmsessionitem(plmPlenumSessionID: int): - data = DB.get_single_data('plenum_kns_plmsessionitem', - 'plmPlenumSessionID', - plmPlenumSessionID) +@app.get( + '/committees_document_background_material_titles/{DocumentCommitteeSessionID}', + response_model=committees.DocumentBackgroundMaterialTitles, + responses={ + 404: errors.NO_DATA_FOUND_ERROR}, + tags=["committees"]) +async def get_background_material_title(DocumentCommitteeSessionID: int): + """Route for single "committees_document_background_material_titles" table""" + data = DB.get_single_data('committees_document_background_material_titles', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list lobbyists_v_lobbyist_clients table -@app.get("/lobbyists_v_lobbyist_clients/list", status_code=200, - response_model=List[lobbyists.LobbyistClients], - responses={422: errors.LIMIT_ERROR}, - tags=["lobbyists"]) -async def get_lobbyist_clients_list( +@app.get("/committees_joined_meetings/list", + status_code=200, + response_model=List[committees.JoinedMeetings], + responses={422: errors.LIMIT_ERROR}, + tags=["committees"]) +async def get_joined_meetings_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - LobbyistID: Optional[int] = None, - ClientID: Optional[int] = None, - Name: Optional[str] = None, - ClientsNames: Optional[str] = None + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + CommitteeID: Optional[int] = None, + Location: Optional[str] = None, + SessionUrl: Optional[str] = None, + BroadcastUrl: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + Note: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + protocol_extension: Optional[str] = None, + text_filename: Optional[str] = None, + parts_filename: Optional[str] = None, + topics: Optional[str] = None ): + """Route for committees_joined_meetings table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] + arrays = [[topics]] + var_names = ["topics"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in var_names: + elemts = arrays[var_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM lobbyists_v_lobbyist_clients" + query = "SELECT * FROM committees_joined_meetings" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/committees_joined_meetings/{CommitteeSessionID}', + response_model=committees.JoinedMeetings, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_joined_meeting(CommitteeSessionID: int): + """Route for single "committees_joined_meetings" table""" + data = DB.get_single_data('committees_joined_meetings', + 'CommitteeSessionID', + CommitteeSessionID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list laws_kns_israel_law table -@app.get("/laws_kns_israel_law/list", +@app.get("/committees_kns_cmtsitecode/list", status_code=200, - response_model=List[laws.IsraelLaw], + response_model=List[committees.KnsCmtSitecode], responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_israel_law_list( + tags=["committees"]) +async def get_cmtsitecode_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - IsBasicLaw: Optional[bool] = None, - IsFavoriteLaw: Optional[bool] = None, - IsBudgetLaw: Optional[bool] = None, - PublicationDate: Optional[datetime] = None, - LatestPublicationDate: Optional[str] = None, - LawValidityID: Optional[int] = None, - LawValidityDesc: Optional[str] = None, - ValidityStartDate: Optional[datetime] = None, - ValidityStartDateNotes: Optional[str] = None, - ValidityFinishDate: Optional[datetime] = None, - ValidityFinishDateNotes: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + KnsID: Optional[int] = None, + SiteId: Optional[int] = None ): + """Route for list committees_kns_cmtsitecode table""" query_params = request.query_params.items() + order_by = '"CmtSiteCode" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_israel_law" + query = "SELECT * FROM committees_kns_cmtsitecode" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - return JSONResponse(content={'error': 'LimitError','msg':str(data)}, - status_code=response_status) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + + +@app.get('/committees_kns_cmtsitecode/{CmtSiteCode}', + response_model=committees.KnsCmtSitecode, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_cmt_site_code(CmtSiteCode: int): + """Route for single "committees_kns_cmtsitecode" table""" + data = DB.get_single_data('committees_kns_cmtsitecode', + 'CmtSiteCode', CmtSiteCode) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get("/committees_meeting_protocols_parts/list", + status_code=200, + response_model=List[committees.MeetingProtocolsParts], + responses={422: errors.LIMIT_ERROR}, + tags=["committees"]) +async def get_meeting_protocols_parts_list( + request: Request, + limit: int = 100, + offset: int = 0, + CommitteeSessionID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + KnessetNum: Optional[int] = None, + protocol_extension: Optional[str] = None, + parsed_filename: Optional[str] = None, + filesize: Optional[int] = None, + crc32c: Optional[str] = None, + error: Optional[str] = None +): + """Route for list committees_meeting_protocols_parts table""" + query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' + qs_parts = [] + for key, value in query_params: + if key not in ['limit', 'offset', 'order_by']: + qs_parts.append(f"{key}={value}") + qs = '&'.join(qs_parts) + query = "SELECT * FROM committees_meeting_protocols_parts" + data = DB.get_data_list(query, limit, offset, order_by, qs) + if isinstance(data, Exception): + response_status = (status.HTTP_404_NOT_FOUND + if isinstance(data, TypeError) + else status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for single "laws_kns_israel_law" table -@app.get('/laws_kns_israel_law/{IsraelLawID}', - response_model=laws.IsraelLaw, +@app.get('/committees_meeting_protocols_parts/{DocumentCommitteeSessionID}', + response_model=committees.MeetingProtocolsParts, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_israel_law(IsraelLawID: int): - data = DB.get_single_data('laws_kns_israel_law', - 'IsraelLawID', IsraelLawID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_meeting_protocols_parts(DocumentCommitteeSessionID: int): + """Route for single "committees_meeting_protocols_parts" table""" + data = DB.get_single_data('committees_meeting_protocols_parts', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for votes_vote_result_type table -@app.get("/votes_vote_result_type/list", +@app.get("/committees_build_rendered_meetings_stats/list", status_code=200, - response_model=List[votes.VoteResultType], + response_model=List[committees.BuildRenderedMeetingsStats], responses={422: errors.LIMIT_ERROR}, - tags=["votes"]) -async def get_vote_result_type_list( + tags=["committees"]) +async def get_build_rendered_meetings_stats_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - result_type_name: Optional[str] = None + num_speech_parts: Optional[int] = None ): + """Route for list committees_build_rendered_meetings_stats table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM votes_vote_result_type" + query = "SELECT * FROM committees_build_rendered_meetings_stats" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "votes_vote_result_type" table -@app.get('/votes_vote_result_type/{result_type_id}', +@app.get('/committees_build_rendered_meetings_stats/{CommitteeSessionID}', + response_model=committees.BuildRenderedMeetingsStats, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["votes"]) -async def get_vote_result_type(result_type_id: int): - data = DB.get_single_data('votes_vote_result_type', - 'result_type_id', result_type_id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_rendered_meetings_stats(CommitteeSessionID: int): + """Route for single "committees_build_rendered_meetings_stats" table""" + data = DB.get_single_data('committees_build_rendered_meetings_stats', + 'CommitteeSessionID', + CommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get("/committees_kns_committeesession/list", + status_code=200, + response_model=List[committees.KnsCommitteeSession], + responses={422: errors.LIMIT_ERROR}, + tags=["committees"]) +async def get_committeesession_list( + request: Request, + limit: int = 100, + offset: int = 0, + CommitteeSessionID: Optional[int] = None, + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + CommitteeID: Optional[int] = None, + Location: Optional[str] = None, + SessionUrl: Optional[str] = None, + BroadcastUrl: Optional[str] = None, + StartDate: Optional[date] = None, + FinishDate: Optional[datetime] = None, + Note: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + download_crc32c: Optional[str] = None, + download_filename: Optional[str] = None, + download_filesize: Optional[int] = None, + parts_crc32c: Optional[str] = None, + parts_filesize: Optional[int] = None, + parts_parsed_filename: Optional[str] = None, + text_crc32c: Optional[str] = None, + text_filesize: Optional[int] = None, + text_parsed_filename: Optional[str] = None, + item_ids: List[int] = Query([], example=[], list=True), + item_type_ids: List[int] = Query([], example=[], list=True), + topics: Optional[str] = None, + committee_name: Optional[str] = None, + bill_names: Optional[str] = None, + bill_types: Optional[str] = None, + related_to_legislation: Optional[bool] = None +): + """Route for list committees_kns_committeesession table""" + query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' + qs_parts = [] + arrays = [item_ids, item_type_ids, [topics], [bill_names], [bill_types]] + var_names = ["item_ids", "item_type_ids", "topics", "bill_names", + "bill_types"] + for key, value in query_params: + if key in var_names: + elemts = arrays[var_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: + qs_parts.append(f"{key}={value}") + qs = '&'.join(qs_parts) + query = "SELECT * FROM committees_kns_committeesession" + data = DB.get_data_list(query, limit, offset, order_by, qs) + if isinstance(data, Exception): + response_status = (status.HTTP_404_NOT_FOUND + if isinstance(data, TypeError) + else status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list committees_kns_documentcommitteesession table @app.get("/committees_kns_documentcommitteesession/list", status_code=200, response_model=List[committees.KnsDocumentCommitteeSession], @@ -2484,7 +3040,6 @@ async def get_documentcommitteesession_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, DocumentCommitteeSessionID: Optional[int] = None, CommitteeSessionID: Optional[int] = None, GroupTypeID: Optional[int] = None, @@ -2508,7 +3063,9 @@ async def get_documentcommitteesession_list( parts_crc32c: Optional[str] = None, parts_error: Optional[str] = None ): + """Route for list committees_kns_documentcommitteesession table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: @@ -2517,375 +3074,428 @@ async def get_documentcommitteesession_list( query = "SELECT * FROM committees_kns_documentcommitteesession" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for lobbyists_v_lobbyist table -@app.get("/lobbyists_v_lobbyist/list", +@app.get("/committees_kns_cmtsessionitem/list", status_code=200, - response_model=List[lobbyists.Lobbyist], + response_model=List[committees.KnsCmtSessionItem], responses={422: errors.LIMIT_ERROR}, - tags=["lobbyists"]) -async def get_lobbyist_list( + tags=["committees"]) +async def get_cmtsessionitem_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - IdentityNumber: Optional[str] = None, - FullName: Optional[str] = None, - PermitTypeValue: Optional[str] = None, - Key: Optional[int] = None, - CorporationName: Optional[str] = None, - IsIndependent: Optional[bool] = None, - CorpNumber: Optional[int] = None, - PracticeFramework: Optional[str] = None, - IsMemberInFaction: Optional[str] = None, - MemberInFaction: Optional[str] = None + ItemID: Optional[int] = None, + CommitteeSessionID: Optional[int] = None, + Ordinal: Optional[int] = None, + StatusID: Optional[int] = None, + Name: Optional[str] = None, + ItemTypeID: Optional[int] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list committees_kns_cmtsessionitem table""" query_params = request.query_params.items() + order_by = '"CmtSessionItemID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM lobbyists_v_lobbyist" + query = "SELECT * FROM committees_kns_cmtsessionitem" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "lobbyists_v_lobbyist" table -@app.get('/lobbyists_v_lobbyist/{LobbyistID}', - response_model=lobbyists.Lobbyist, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["lobbyists"]) -async def get_lobbyist(LobbyistID: int): - data = DB.get_single_data('lobbyists_v_lobbyist', - 'LobbyistID', LobbyistID) +@app.get('/committees_kns_cmtsessionitem/{CmtSessionItemID}', + response_model=committees.KnsCmtSessionItem, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_cmtsessionitem(CmtSessionItemID: int): + """Route for "committees_kns_cmtsessionitem" table""" + data = DB.get_single_data('committees_kns_cmtsessionitem', + 'CmtSessionItemID', + CmtSessionItemID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list laws_kns_israel_law_binding table -@app.get("/laws_kns_israel_law_binding/list", +@app.get("/committees_document_committee_sessions_for_parsing/list", status_code=200, - response_model=List[laws.IsraelLawBinding], + response_model=List[committees.DocumentCommitteeSessionsParsing], responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_israel_law_binding_list( + tags=["committees"]) +async def get_committee_sessions_for_parsing_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - IsraelLawID: Optional[int] = None, - IsraelLawReplacedID: Optional[int] = None, - LawID: Optional[int] = None, - LawTypeID: Optional[int] = None, - LastUpdatedDate: Optional[datetime] = None + CommitteeSessionID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + KnessetNum: Optional[int] = None ): + """Route for list committees_document_committee_sessions_for_parsing table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_israel_law_binding" + query = "SELECT * FROM committees_document_committee_sessions_for_parsing" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "laws_kns_israel_law_binding" table -@app.get('/laws_kns_israel_law_binding/{IsraelLawBinding}', - response_model=laws.IsraelLawBinding, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_israel_law_binding(IsraelLawBinding: int): - data = DB.get_single_data('laws_kns_israel_law_binding', - 'IsraelLawBinding', IsraelLawBinding) +@app.get( + '/committees_document_committee_sessions_for_parsing/{DocumentCommitteeSessionID}', + response_model=committees.DocumentCommitteeSessionsParsing, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_document_committee_sessions_for_parsing(DocumentCommitteeSessionID: int): + """Route for single "committees_document_committee_sessions_for_parsing" table""" + data = DB.get_single_data + ( + 'committees_document_committee_sessions_for_parsing', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID + ) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_plenum_session_voters table -@app.get("/people_plenum_session_voters/list", +@app.get("/committees_download_document_committee_session/list", status_code=200, - response_model=List[people.PlenumSessionVoters], + response_model=List[committees.DownloadDocumentCommitteeSession], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_plenum_session_voters_list( + tags=["committees"]) +async def get_download_document_committee_session_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Number: Optional[int] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - IsSpecialMeeting: Optional[bool] = None, + CommitteeSessionID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None, - voter_mk_ids: List[int] = Query([], example=[], list=True) + KnessetNum: Optional[int] = None, + filename: Optional[str] = None, + filesize: Optional[int] = None, + crc32c: Optional[str] = None, + error: Optional[str] = None ): + """Route for list committees_download_document_committee_session table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] - arrays = [voter_mk_ids] - var_names = ["voter_mk_ids"] for key, value in query_params: - if key in var_names: - elemts = arrays[var_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_plenum_session_voters" + query = "SELECT * FROM committees_download_document_committee_session" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "people_plenum_session_voters" table -@app.get('/people_plenum_session_voters/{PlenumSessionID}', - response_model=people.PlenumSessionVoters, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["people"]) -async def get_plenum_session_voters(PlenumSessionID: int): - data = DB.get_single_data('people_plenum_session_voters', - 'PlenumSessionID', PlenumSessionID) +@app.get( + '/committees_download_document_committee_session/{DocumentCommitteeSessionID}', + response_model=committees.DownloadDocumentCommitteeSession, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_download_document_committee_session(DocumentCommitteeSessionID: int): + """Route for single "committees_download_document_committee_session" table""" + data = DB.get_single_data('committees_download_document_committee_session', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_mk_voted_against_majority table -@app.get("/people_mk_voted_against_majority/list", +@app.get("/committees_meeting_protocols_text/list", status_code=200, - response_model=List[people.MkVotedAgainstMajority], + response_model=List[committees.MeetingProtocolsText], responses={422: errors.LIMIT_ERROR}, - tags=["people"]) -async def get_mk_voted_against_majority_list( + tags=["committees"]) +async def get_committee_meeting_protocols_text_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - vote_id: Optional[int] = None, - mk_id: Optional[int] = None, - faction_id: Optional[int] = None, - vote_knesset: Optional[int] = None, - vote_plenum: Optional[int] = None, - vote_assembly: Optional[int] = None, - vote_pagra: Optional[bool] = None, - vote_datetime: Optional[datetime] = None, - vote_majority: Optional[str] = None, - voted_against_majority: Optional[bool] = None + CommitteeSessionID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + KnessetNum: Optional[int] = None, + protocol_extension: Optional[str] = None, + parsed_filename: Optional[str] = None, + filesize: Optional[str] = None, + crc32c: Optional[str] = None, + error: Optional[str] = None ): + """Route for list committees_meeting_protocols_text table""" query_params = request.query_params.items() + order_by = '"DocumentCommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_mk_voted_against_majority" + query = "SELECT * FROM committees_meeting_protocols_text" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/committees_meeting_protocols_text/{DocumentCommitteeSessionID}', + response_model=committees.MeetingProtocolsText, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_meeting_protocols_text(DocumentCommitteeSessionID: int): + """Route for single "committees_meeting_protocols_text" table""" + data = DB.get_single_data('committees_meeting_protocols_text', + 'DocumentCommitteeSessionID', + DocumentCommitteeSessionID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list committees_kns_cmtsessionitem table -@app.get("/committees_kns_cmtsessionitem/list", +@app.get("/committees_kns_committee/list", status_code=200, - response_model=List[committees.KnsCmtSessionItem], + response_model=List[committees.KnsCommittee], responses={422: errors.LIMIT_ERROR}, tags=["committees"]) -async def get_cmtsessionitem_list( +async def get_committee_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - ItemID: Optional[int] = None, - CommitteeSessionID: Optional[int] = None, - Ordinal: Optional[int] = None, - StatusID: Optional[int] = None, Name: Optional[str] = None, - ItemTypeID: Optional[int] = None, + CategoryID: Optional[int] = None, + CategoryDesc: Optional[str] = None, + KnessetNum: Optional[int] = None, + CommitteeTypeID: Optional[int] = None, + CommitteeTypeDesc: Optional[str] = None, + Email: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + AdditionalTypeID: Optional[int] = None, + AdditionalTypeDesc: Optional[str] = None, + ParentCommitteeID: Optional[int] = None, + CommitteeParentName: Optional[str] = None, + IsCurrent: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list committees_kns_committee table""" query_params = request.query_params.items() + order_by = '"CommitteeID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_cmtsessionitem" + query = "SELECT * FROM committees_kns_committee" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "committees_kns_cmtsessionitem" table -@app.get('/committees_kns_cmtsessionitem/{CmtSessionItemID}', - response_model=committees.KnsCmtSessionItem, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_cmtsessionitem(CmtSessionItemID: int): - data = DB.get_single_data('committees_kns_cmtsessionitem', - 'CmtSessionItemID', - CmtSessionItemID) +@app.get('/committees_kns_committee/{CommitteeID}', + response_model=committees.KnsCommittee, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["committees"]) +async def get_single_data(CommitteeID: int): + """Route for single "committees_kns_committee" table""" + data = DB.get_single_data('committees_kns_committee', + 'CommitteeID', CommitteeID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list laws_kns_israel_law_ministry table -@app.get("/laws_kns_israel_law_ministry/list", +@app.get("/people_committees_joined_meetings/list", status_code=200, - response_model=List[laws.IsraelLawMinistry], + response_model=List[people.CommitteesJoinedMeetings], responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_israel_law_ministry_list( + tags=["people"]) +async def get_people_committees_joined_meetings_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - IsraelLawID: Optional[int] = None, - GovMinistryID: Optional[int] = None, - LastUpdatedDate: Optional[datetime] = None + CommitteeSessionID: Optional[int] = None, + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + CommitteeID: Optional[int] = None, + Location: Optional[str] = None, + SessionUrl: Optional[str] = None, + BroadcastUrl: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + Note: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None, + text_file_name: Optional[str] = None, + text_file_size: Optional[int] = None, + topics: List[str] = Query( + [], + alias="topics", + example=['שינויים בתקציב לשנת 2003'], + list=True + ) ): + """Route for list people_committees_joined_meetings table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] + arrays = [topics] + var_names = ["topics"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in var_names: + elemts = arrays[var_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_israel_law_ministry" + query = "SELECT * FROM people_committees_joined_meetings" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "laws_kns_israel_law_ministry" table -@app.get('/laws_kns_israel_law_ministry/{LawMinistryID}', - response_model=laws.IsraelLawMinistry, +@app.get('/people_committees_joined_meetings/{CommitteeSessionID}', + response_model=people.CommitteesJoinedMeetings, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_israel_law_ministry(LawMinistryID: int): - data = DB.get_single_data('laws_kns_israel_law_ministry', - 'LawMinistryID', LawMinistryID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["people"]) +async def get_people_committees_joined_meeting(CommitteeSessionID: int): + """Route for single "people_committees_joined_meetings" table""" + data = DB.get_single_data('people_committees_joined_meetings', + 'CommitteeSessionID', CommitteeSessionID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_mk_party_discipline_knesset_20 table -@app.get("/people_mk_party_discipline_knesset_20/list", +@app.get("/people_committees_meeting_attendees/list", status_code=200, - response_model=List[people.MkPartyDisciplineKnesset20], + response_model=List[people.CommitteesMeetingAttendees], responses={422: errors.LIMIT_ERROR}, tags=["people"]) -async def get_mk_party_discipline_knesset_20_list( +async def get_committees_meeting_attendees_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - vote_id: Optional[int] = None, - vote_url: Optional[str] = None, - vote_datetime: Optional[datetime] = None, - vote_knesset: Optional[int] = None, - vote_plenum: Optional[int] = None, - vote_assembly: Optional[int] = None, - vote_pagra: Optional[bool] = None, - mk_id: Optional[int] = None, - mk_name: Optional[str] = None, - faction_id: Optional[int] = None, - faction_name: Optional[str] = None, - vote_majority: Optional[str] = None -): - query_params = request.query_params.items() - qs_parts = [] - for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: - qs_parts.append(f"{key}={value}") - qs = '&'.join(qs_parts) - query = "SELECT * FROM people_mk_party_discipline_knesset_20" - data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND - if isinstance(data, TypeError) - else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for list committees_kns_committeesession table -@app.get("/committees_kns_committeesession/list", - status_code=200, - response_model=List[committees.KnsCommitteeSession], - responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_committeesession_list( - request: Request, - limit: int = 100, - offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, Number: Optional[int] = None, KnessetNum: Optional[int] = None, TypeID: Optional[int] = None, @@ -2894,7 +3504,7 @@ async def get_committeesession_list( Location: Optional[str] = None, SessionUrl: Optional[str] = None, BroadcastUrl: Optional[str] = None, - StartDate: Optional[date] = None, + StartDate: Optional[datetime] = None, FinishDate: Optional[datetime] = None, Note: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None, @@ -2907,349 +3517,421 @@ async def get_committeesession_list( text_crc32c: Optional[str] = None, text_filesize: Optional[int] = None, text_parsed_filename: Optional[str] = None, - item_ids: List[int] = Query([], example=[], list=True), - item_type_ids: List[int] = Query([], example=[], list=True), + item_ids: List[int] = Query( + [], + alias="item_ids", + example=[74814], + list=True + ), + item_type_ids: List[int] = Query( + [], + alias="item_type_ids", + example=[11], + list=True + ), topics: Optional[str] = None, committee_name: Optional[str] = None, bill_names: Optional[str] = None, bill_types: Optional[str] = None, - related_to_legislation: Optional[bool] = None + related_to_legislation: Optional[bool] = None, + mks: Optional[str] = None, + invitees_name: Optional[str] = None, + legal_advisors: Optional[str] = None, + manager: Optional[str] = None, + financial_advisors: Optional[str] = None, + attended_mk_individual_ids: List[int] = Query( + [], + alias="attended_mk_individual_ids", + example=[], + list=True + ) ): + """Route for list people_committees_meeting_attendees table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] - arrays = [item_ids, item_type_ids, [topics], [bill_names], [bill_types]] - var_names = ["item_ids", "item_type_ids", "topics", "bill_names", - "bill_types"] + arrays_number_val = [item_ids, item_type_ids, attended_mk_individual_ids] + arrays_number_names = ["item_ids", "item_type_ids", + "attended_mk_individual_ids"] + arrays_val = [[topics], [bill_names], [bill_types], [mks], + [legal_advisors], [manager], [financial_advisors]] + arrays_name = ["topics", "bill_names", "bill_types", "mks", + "legal_advisors", "manager", "financial_advisors"] + objects_val = [invitees_name] + objects_name = ["invitees_name"] for key, value in query_params: - if key in var_names: - elemts = arrays[var_names.index(key)] + if key in arrays_number_names: + elemts = arrays_number_val[arrays_number_names.index(key)] qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + elif key not in ['limit', 'offset', 'order_by'] and \ + key not in arrays_name and \ + key not in objects_name: qs_parts.append(f"{key}={value}") + + for name, val in zip(arrays_name, arrays_val): + if val[0]: + qs_parts.append(f"{name}={val}") + for name, val in zip(objects_name, objects_val): + if val: + qs_parts.append(f"{name}=<{val}>") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_committeesession" + query = "SELECT * FROM people_committees_meeting_attendees" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get('/people_committees_meeting_attendees/{CommitteeSessionID}', + response_model=people.CommitteesMeetingAttendees, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["people"]) +async def get_meeting_attendees(CommitteeSessionID: int): + """Route for single "people_committees_meeting_attendees" table""" + data = DB.get_single_data('people_committees_meeting_attendees', + 'CommitteeSessionID', + CommitteeSessionID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for list members_kns_mksitecode table -@app.get("/members_kns_mksitecode/list", +@app.get("/people_mk_party_discipline_stats/list", status_code=200, - response_model=List[members.Mksitecode], + response_model=List[people.PartyDisciplineStats], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_mksitecode_list( + tags=["people"]) +async def get_mk_party_discipline_stats_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - KnsID: Optional[int] = None, - SiteId: Optional[int] = None + knesset: Optional[int] = None, + plenum: Optional[int] = None, + assembly: Optional[int] = None, + pagra: Optional[int] = None, + faction_id: Optional[int] = None, + mk_id: Optional[int] = None, + undisciplined_votes: Optional[int] = None, + disciplined_votes: Optional[int] = None, + total_votes: Optional[int] = None, + undisciplined_votes_percent: Optional[int] = None, + disciplined_votes_percent: Optional[int] = None ): + """Route for list people_mk_party_discipline_stats table""" query_params = request.query_params.items() + order_by = "knesset desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_kns_mksitecode" + query = "SELECT * FROM people_mk_party_discipline_stats" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "members_kns_mksitecode" table -@app.get('/members_kns_mksitecode/{MKSiteCode}', - response_model=members.Mksitecode, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_mksitecode(MKSiteCode: int): - data = DB.get_single_data('members_kns_mksitecode', - 'MKSiteCode', MKSiteCode) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_meeting_attendees_mks_stats table -@app.get("/people_committees_meeting_attendees_mks_stats/list", +@app.get("/people_committees_meeting_attendees_mks_full_stats/list", status_code=200, - response_model=List[people.CommitteesMeetingAttendeesMksStats], + response_model=List[people.CommitteesMeetingAttendeesMksFullStats], responses={422: errors.LIMIT_ERROR}, tags=["people"]) -async def get_committee_attendees_mks_stats_list( +async def get_attendees_mks_full_stats_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - knesset_num: Optional[int] = None, + knesset: Optional[int] = None, + plenum: Optional[int] = None, + assembly: Optional[int] = None, + pagra: Optional[int] = None, committee_id: Optional[int] = None, - committee_name: Optional[str] = None, - meeting_start_date: Optional[datetime] = None, - meeting_topics: Optional[str] = None, + faction_id: Optional[int] = None, mk_id: Optional[int] = None, - mk_name: Optional[str] = None, - mk_membership_committee_names: Optional[str] = None, - mk_faction_id: Optional[int] = None, - mk_faction_name: Optional[str] = None + attended_meetings: Optional[int] = None, + protocol_meetings: Optional[int] = None, + open_meetings: Optional[int] = None, + attended_meetings_percent: Optional[int] = None, + attended_meetings_relative_percent: Optional[int] = None ): + """Route for list people_committees_meeting_attendees_mks_full_stats table""" query_params = request.query_params.items() + order_by = "knesset desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM people_committees_meeting_attendees_mks_stats" + query = "SELECT * FROM people_committees_meeting_attendees_mks_full_stats" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for laws_kns_law table -@app.get("/laws_kns_law/list", - status_code=200, - response_model=List[laws.KnsLaw], - responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_law_list( +@app.get("/people_committees_meeting_speaker_stats/list", + status_code=200, + response_model=List[people.CommitteesMeetingSpeakerStats], + responses={422: errors.LIMIT_ERROR}, + tags=["people"]) +async def get_meeting_speaker_stats_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - TypeID: Optional[int] = None, - TypeDesc: Optional[str] = None, - SubTypeID: Optional[int] = None, - SubTypeDesc: Optional[str] = None, - KnessetNum: Optional[int] = None, - Name: Optional[str] = None, - PublicationDate: Optional[datetime] = None, - PublicationSeriesID: Optional[int] = None, - PublicationSeriesDesc: Optional[str] = None, - MagazineNumber: Optional[str] = None, - PageNumber: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + CommitteeSessionID: Optional[int] = None, + parts_crc32c: Optional[str] = None, + part_index: Optional[int] = None, + header: Optional[str] = None, + body_length: Optional[int] = None, + body_num_words: Optional[int] = None, + part_categories: Optional[str] = None, + name_role: Optional[str] = None, + mk_individual_id: Optional[int] = None, + mk_individual_faction: Optional[str] = None ): + """Route for list people_committees_meeting_speaker_stats table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_law" + query = "SELECT * FROM people_committees_meeting_speaker_stats" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "laws_kns_law" table -@app.get('/laws_kns_law/{LawID}', - response_model=laws.KnsLaw, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_law(LawID: int): - data = DB.get_single_data('laws_kns_law', 'LawID', LawID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_document_committee_sessions_for_parsing table -@app.get("/committees_document_committee_sessions_for_parsing/list", +@app.get("/people_plenum_session_voters/list", status_code=200, - response_model=List[committees.DocumentCommitteeSessionsParsing], + response_model=List[people.PlenumSessionVoters], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_committee_sessions_for_parsing_list( + tags=["people"]) +async def get_plenum_session_voters_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, + Number: Optional[int] = None, + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + StartDate: Optional[datetime] = None, + FinishDate: Optional[datetime] = None, + IsSpecialMeeting: Optional[bool] = None, LastUpdatedDate: Optional[datetime] = None, - KnessetNum: Optional[int] = None + voter_mk_ids: List[int] = Query([], example=[], list=True) ): + """Route for list people_plenum_session_voters table""" query_params = request.query_params.items() + order_by = '"PlenumSessionID" desc' qs_parts = [] + arrays = [voter_mk_ids] + var_names = ["voter_mk_ids"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key in var_names: + elemts = arrays[var_names.index(key)] + qs_parts.append(f"{key}={elemts}") + elif key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_document_committee_sessions_for_parsing" + query = "SELECT * FROM people_plenum_session_voters" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_document_committee_sessions_for_parsing" table -@app.get('/committees_document_committee_sessions_for_parsing/{DocumentCommitteeSessionID}', - response_model=committees.DocumentCommitteeSessionsParsing, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_document_committee_sessions_for_parsing(DocumentCommitteeSessionID: int): - data = DB.get_single_data - ( - 'committees_document_committee_sessions_for_parsing', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID - ) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data +@app.get('/people_plenum_session_voters/{PlenumSessionID}', + response_model=people.PlenumSessionVoters, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["people"]) +async def get_plenum_session_voters(PlenumSessionID: int): + """Route for single "people_plenum_session_voters" table""" + data = DB.get_single_data('people_plenum_session_voters', + 'PlenumSessionID', PlenumSessionID) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data -# Route for list committees_download_document_committee_session table -@app.get("/committees_download_document_committee_session/list", +@app.get("/people_mk_voted_against_majority/list", status_code=200, - response_model=List[committees.DownloadDocumentCommitteeSession], + response_model=List[people.MkVotedAgainstMajority], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_download_document_committee_session_list( + tags=["people"]) +async def get_mk_voted_against_majority_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - KnessetNum: Optional[int] = None, - filename: Optional[str] = None, - filesize: Optional[int] = None, - crc32c: Optional[str] = None, - error: Optional[str] = None + vote_id: Optional[int] = None, + mk_id: Optional[int] = None, + faction_id: Optional[int] = None, + vote_knesset: Optional[int] = None, + vote_plenum: Optional[int] = None, + vote_assembly: Optional[int] = None, + vote_pagra: Optional[bool] = None, + vote_datetime: Optional[datetime] = None, + vote_majority: Optional[str] = None, + voted_against_majority: Optional[bool] = None ): + """Route for list people_mk_voted_against_majority table""" query_params = request.query_params.items() + order_by = "vote_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_download_document_committee_session" + query = "SELECT * FROM people_mk_voted_against_majority" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "committees_download_document_committee_session" table -@app.get('/committees_download_document_committee_session/{DocumentCommitteeSessionID}', - response_model=committees.DownloadDocumentCommitteeSession, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_download_document_committee_session(DocumentCommitteeSessionID: int): - data = DB.get_single_data('committees_download_document_committee_session', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list laws_kns_israel_law_name table -@app.get("/laws_kns_israel_law_name/list", +@app.get("/people_mk_party_discipline_knesset_20/list", status_code=200, - response_model=List[laws.IsraelLawName], + response_model=List[people.MkPartyDisciplineKnesset20], responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_israel_law_name_list( + tags=["people"]) +async def get_mk_party_discipline_knesset_20_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - IsraelLawID: Optional[int] = None, - LawID: Optional[int] = None, - LawTypeID: Optional[int] = None, - Name: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + vote_id: Optional[int] = None, + vote_url: Optional[str] = None, + vote_datetime: Optional[datetime] = None, + vote_knesset: Optional[int] = None, + vote_plenum: Optional[int] = None, + vote_assembly: Optional[int] = None, + vote_pagra: Optional[bool] = None, + mk_id: Optional[int] = None, + mk_name: Optional[str] = None, + faction_id: Optional[int] = None, + faction_name: Optional[str] = None, + vote_majority: Optional[str] = None ): + """Route for list people_mk_party_discipline_knesset_20 table""" query_params = request.query_params.items() + order_by = "vote_id desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_israel_law_name" + query = "SELECT * FROM people_mk_party_discipline_knesset_20" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "laws_kns_israel_law_name" table -@app.get('/laws_kns_israel_law_name/{IsraelLawNameID}', - response_model=laws.IsraelLawName, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["laws"]) -async def get_israel_law_name(IsraelLawNameID: int): - data = DB.get_single_data('laws_kns_israel_law_name', - 'IsraelLawNameID', IsraelLawNameID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) +@app.get("/people_committees_meeting_attendees_mks_stats/list", + status_code=200, + response_model=List[people.CommitteesMeetingAttendeesMksStats], + responses={422: errors.LIMIT_ERROR}, + tags=["people"]) +async def get_committee_attendees_mks_stats_list( + request: Request, + limit: int = 100, + offset: int = 0, + knesset_num: Optional[int] = None, + committee_id: Optional[int] = None, + committee_name: Optional[str] = None, + meeting_start_date: Optional[datetime] = None, + meeting_topics: Optional[str] = None, + mk_id: Optional[int] = None, + mk_name: Optional[str] = None, + mk_membership_committee_names: Optional[str] = None, + mk_faction_id: Optional[int] = None, + mk_faction_name: Optional[str] = None +): + """Route for list people_committees_meeting_attendees_mks_stats table""" + query_params = request.query_params.items() + order_by = "knesset_num desc" + qs_parts = [] + for key, value in query_params: + if key not in ['limit', 'offset', 'order_by']: + qs_parts.append(f"{key}={value}") + qs = '&'.join(qs_parts) + query = "SELECT * FROM people_committees_meeting_attendees_mks_stats" + data = DB.get_data_list(query, limit, offset, order_by, qs) + if isinstance(data, Exception): + response_status = (status.HTTP_404_NOT_FOUND + if isinstance(data, TypeError) + else status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_members_joined_mks table @app.get("/people_members_joined_mks/list", status_code=200, response_model=List[people.MembersJoinedMks], @@ -3259,7 +3941,6 @@ async def get_joined_mks_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, mk_status_id: Optional[int] = None, mk_individual_name: Optional[str] = None, mk_individual_name_eng: Optional[str] = None, @@ -3285,235 +3966,78 @@ async def get_joined_mks_list( positions_FactionName: Optional[str] = None, positions_CommitteeID: Optional[int] = None, positions_CommitteeName: Optional[str] = None, - positions_DutyDesc: Optional[str] = None, - positions_GovMinistryID: Optional[int] = None, - positions_GovernmentNum: Optional[int] = None, - positions_GovMinistryName: Optional[str] = None, - altnames: Optional[str] = None -): - query_params = request.query_params.items() - qs_parts = [] - arrays_val = [[altnames]] - arrays_name = ["altnames"] - objects_val = [positions_gender, positions_position, - positions_KnessetNum, positions_start_date, - positions_finish_date, positions_position_id, - positions_FactionID, positions_FactionName, - positions_CommitteeID, positions_CommitteeName, - positions_DutyDesc, positions_GovMinistryID, - positions_GovernmentNum, positions_GovMinistryName] - objects_name = ["positions_gender", "positions_position", - "positions_KnessetNum", "positions_start_date", - "positions_finish_date", "positions_position_id", - "positions_FactionID", "positions_FactionName", - "positions_CommitteeID", "positions_CommitteeName", - "positions_DutyDesc", "positions_GovMinistryID", - "positions_GovernmentNum", "positions_GovMinistryName"] - for key, value in query_params: - if key not in ['limit', 'offset', 'order_by'] and \ - key not in objects_name and \ - key not in arrays_name: - qs_parts.append(f"{key}={value}") - for name, val in zip(arrays_name, arrays_val): - if val[0]: - qs_parts.append(f"{name}={val}") - for name, val in zip(objects_name, objects_val): - if val: - qs_parts.append(f"{name}=<{val}>") - qs = '&'.join(qs_parts) - query = "SELECT * FROM people_members_joined_mks" - data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND - if isinstance(data, TypeError) - else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "people_members_joined_mks" table -@app.get('/people_members_joined_mks/{mk_individual_id}', - response_model=people.MembersJoinedMks, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["people"]) -async def get_members_joined_mks(mk_individual_id: int): - data = DB.get_single_data('people_members_joined_mks', - 'mk_individual_id', mk_individual_id) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for list laws_kns_law_binding table -@app.get("/laws_kns_law_binding/list", - status_code=200, - response_model=List[laws.LawBinding], - responses={422: errors.LIMIT_ERROR}, - tags=["laws"]) -async def get_law_binding_list( - request: Request, - limit: int = 100, - offset: int = 0, - order_by: Optional[str] = None, - LawID: Optional[int] = None, - LawTypeID: Optional[int] = None, - IsraelLawID: Optional[int] = None, - ParentLawID: Optional[int] = None, - LawParentTypeID: Optional[int] = None, - BindingType: Optional[int] = None, - BindingTypeDesc: Optional[str] = None, - PageNumber: Optional[str] = None, - AmendmentType: Optional[int] = None, - AmendmentTypeDesc: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None -): - query_params = request.query_params.items() - qs_parts = [] - for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: - qs_parts.append(f"{key}={value}") - qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_law_binding" - data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND - if isinstance(data, TypeError) - else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "laws_kns_law_binding" table -@app.get('/laws_kns_law_binding/{LawBindingID}', - response_model=laws.LawBinding, - responses={ - 404: errors.NO_DATA_FOUND_ERROR - }, - tags=["laws"]) -async def get_law_binding(LawBindingID: int): - data = DB.get_single_data('laws_kns_law_binding', - 'LawBindingID', LawBindingID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for list knesset_kns_itemtype table -@app.get("/knesset_kns_itemtype/list", - status_code=200, - response_model=List[knesset.KnsItemtype], - responses={422: errors.LIMIT_ERROR}, - tags=["knesset"]) -async def get_knesset_itemtype_list( - request: Request, - limit: int = 100, - offset: int = 0, - order_by: Optional[str] = None, - Desc: Optional[str] = None, - TableName: Optional[str] = None -): - query_params = request.query_params.items() - qs_parts = [] - for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: - qs_parts.append(f"{key}={value}") - qs = '&'.join(qs_parts) - query = "SELECT * FROM knesset_kns_itemtype" - data = DB.get_data_list(query, limit, offset, order_by, qs) - if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND - if isinstance(data, TypeError) - else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for single "knesset_kns_itemtype" table -@app.get('/knesset_kns_itemtype/{ItemTypeID}', - response_model=knesset.KnsItemtype, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["knesset"]) -async def get_itemtype(ItemTypeID: int): - data = DB.get_single_data('knesset_kns_itemtype', 'ItemTypeID', ItemTypeID) - if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) - return data - - - -# Route for list committees_meeting_protocols_text table -@app.get("/committees_meeting_protocols_text/list", - status_code=200, - response_model=List[committees.MeetingProtocolsText], - responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_committee_meeting_protocols_text_list( - request: Request, - limit: int = 100, - offset: int = 0, - order_by: Optional[str] = None, - CommitteeSessionID: Optional[int] = None, - GroupTypeID: Optional[int] = None, - GroupTypeDesc: Optional[str] = None, - ApplicationID: Optional[int] = None, - ApplicationDesc: Optional[str] = None, - FilePath: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None, - KnessetNum: Optional[int] = None, - protocol_extension: Optional[str] = None, - parsed_filename: Optional[str] = None, - filesize: Optional[str] = None, - crc32c: Optional[str] = None, - error: Optional[str] = None + positions_DutyDesc: Optional[str] = None, + positions_GovMinistryID: Optional[int] = None, + positions_GovernmentNum: Optional[int] = None, + positions_GovMinistryName: Optional[str] = None, + altnames: Optional[str] = None ): + """Route for list people_members_joined_mks table""" query_params = request.query_params.items() + order_by = "mk_individual_id desc" qs_parts = [] + arrays_val = [[altnames]] + arrays_name = ["altnames"] + objects_val = [positions_gender, positions_position, + positions_KnessetNum, positions_start_date, + positions_finish_date, positions_position_id, + positions_FactionID, positions_FactionName, + positions_CommitteeID, positions_CommitteeName, + positions_DutyDesc, positions_GovMinistryID, + positions_GovernmentNum, positions_GovMinistryName] + objects_name = ["positions_gender", "positions_position", + "positions_KnessetNum", "positions_start_date", + "positions_finish_date", "positions_position_id", + "positions_FactionID", "positions_FactionName", + "positions_CommitteeID", "positions_CommitteeName", + "positions_DutyDesc", "positions_GovMinistryID", + "positions_GovernmentNum", "positions_GovMinistryName"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by'] and \ + key not in objects_name and \ + key not in arrays_name: qs_parts.append(f"{key}={value}") + for name, val in zip(arrays_name, arrays_val): + if val[0]: + qs_parts.append(f"{name}={val}") + for name, val in zip(objects_name, objects_val): + if val: + qs_parts.append(f"{name}=<{val}>") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_meeting_protocols_text" + query = "SELECT * FROM people_members_joined_mks" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_meeting_protocols_text" table -@app.get('/committees_meeting_protocols_text/{DocumentCommitteeSessionID}', - response_model=committees.MeetingProtocolsText, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_meeting_protocols_text(DocumentCommitteeSessionID: int): - data = DB.get_single_data('committees_meeting_protocols_text', - 'DocumentCommitteeSessionID', - DocumentCommitteeSessionID) +@app.get('/people_members_joined_mks/{mk_individual_id}', + response_model=people.MembersJoinedMks, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["people"]) +async def get_members_joined_mks(mk_individual_id: int): + """Route for single "people_members_joined_mks" table""" + data = DB.get_single_data('people_members_joined_mks', + 'mk_individual_id', mk_individual_id) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list people_committees_meeting_attendees_mks table @app.get("/people_committees_meeting_attendees_mks/list", status_code=200, response_model=List[people.CommitteesMeetingAttendeesMks], @@ -3523,7 +4047,6 @@ async def get_committee_attendees_mks_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, CommitteeSessionID: Optional[int] = None, Number: Optional[int] = None, KnessetNum: Optional[int] = None, @@ -3552,7 +4075,9 @@ async def get_committee_attendees_mks_list( list=True ) ): + """Route for list people_committees_meeting_attendees_mks table""" query_params = request.query_params.items() + order_by = '"CommitteeSessionID" desc' qs_parts = [] arrays_number_val = [attended_mk_individual_ids] arrays_number_names = ["attended_mk_individual_ids"] @@ -3579,575 +4104,647 @@ async def get_committee_attendees_mks_list( query = "SELECT * FROM people_committees_meeting_attendees_mks" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_kns_person table -@app.get("/members_kns_person/list", +@app.get("/people_plenum_session_voters_stats/list", status_code=200, - response_model=List[members.Person], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_person_list( + response_model=List[people.PlenumSessionVotersStats], + tags=["people"]) +async def get_voters_stats_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - PersonID: Optional[int] = None, - LastName: Optional[str] = None, - FirstName: Optional[str] = None, - GenderID: Optional[int] = None, - GenderDesc: Optional[str] = None, - Email: Optional[str] = None, - IsCurrent: Optional[bool] = None, - LastUpdatedDate: Optional[datetime] = None + knesset: Optional[int] = None, + plenum: Optional[int] = None, + assembly: Optional[int] = None, + pagra: Optional[int] = None, + faction_id: Optional[int] = None, + mk_id: Optional[int] = None, + voted_sessions: Optional[int] = None, + total_sessions: Optional[int] = None, + voted_sessions_percent: Optional[int] = None ): + """Route for list people_plenum_session_voters_stats table""" query_params = request.query_params.items() + order_by = "knesset desc" qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_kns_person" + query = "SELECT * FROM people_plenum_session_voters_stats" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data +@app.get("/laws_kns_document_law/list", status_code=200, + response_model=List[laws.DocumentLaw], + responses={422: errors.LIMIT_ERROR}, + tags=["laws"]) +async def get_document_law_list( + request: Request, + limit: int = 100, + offset: int = 0, + LawID: Optional[int] = None, + GroupTypeID: Optional[int] = None, + GroupTypeDesc: Optional[str] = None, + ApplicationID: Optional[int] = None, + ApplicationDesc: Optional[str] = None, + FilePath: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None +): + """Route for list laws_kns_document_law table""" + query_params = request.query_params.items() + order_by = '"DocumentLawID" desc' + qs_parts = [] + for key, value in query_params: + if key not in ['limit', 'offset', 'order_by']: + qs_parts.append(f"{key}={value}") + qs = '&'.join(qs_parts) + query = "SELECT * FROM laws_kns_document_law" + data = DB.get_data_list(query, limit, offset, order_by, qs) + if isinstance(data, Exception): + response_status = (status.HTTP_404_NOT_FOUND + if isinstance(data, TypeError) + else status.HTTP_422_UNPROCESSABLE_ENTITY) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) + return data + -# Route for single "members_kns_person" table -@app.get('/members_kns_person/{PersonID}', - response_model=members.Person, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_person(PersonID: int): - data = DB.get_single_data('members_kns_person', 'PersonID', PersonID) +@app.get('/laws_kns_document_law/{DocumentLawID}', + response_model=laws.DocumentLaw, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_document_law(DocumentLawID: int): + """Route for "laws_kns_document_law" table""" + data = DB.get_single_data('laws_kns_document_law', + 'DocumentLawID', DocumentLawID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_mk_individual table -@app.get("/members_mk_individual/list", +@app.get("/laws_kns_israel_law/list", status_code=200, - response_model=List[members.Individual], + response_model=List[laws.IsraelLaw], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_mk_individual_list( + tags=["laws"]) +async def get_israel_law_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - mk_status_id: Optional[int] = None, - mk_individual_name: Optional[str] = None, - mk_individual_name_eng: Optional[str] = None, - mk_individual_first_name: Optional[str] = None, - mk_individual_first_name_eng: Optional[str] = None, - mk_individual_email: Optional[str] = None, - mk_individual_photo: Optional[str] = None, - PersonID: Optional[int] = None, - LastName: Optional[str] = None, - FirstName: Optional[str] = None, - GenderID: Optional[int] = None, - GenderDesc: Optional[str] = None, - Email: Optional[str] = None, - IsCurrent: Optional[bool] = None, - LastUpdatedDate: Optional[datetime] = None, - altnames: Optional[str] = None, + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + IsBasicLaw: Optional[bool] = None, + IsFavoriteLaw: Optional[bool] = None, + IsBudgetLaw: Optional[bool] = None, + PublicationDate: Optional[datetime] = None, + LatestPublicationDate: Optional[str] = None, + LawValidityID: Optional[int] = None, + LawValidityDesc: Optional[str] = None, + ValidityStartDate: Optional[datetime] = None, + ValidityStartDateNotes: Optional[str] = None, + ValidityFinishDate: Optional[datetime] = None, + ValidityFinishDateNotes: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_israel_law table""" query_params = request.query_params.items() + order_by = '"IsraelLawID" desc' qs_parts = [] - arrays_val = [[altnames]] - arrays_name = ["altnames"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by'] and \ - key not in arrays_name: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") - for name, val in zip(arrays_name, arrays_val): - if val[0]: - qs_parts.append(f"{name}={val}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual" + query = "SELECT * FROM laws_kns_israel_law" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + return JSONResponse(content={'error': 'LimitError', 'msg': str(data)}, + status_code=response_status) + if isinstance(data, TypeError): + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_mk_individual" table -@app.get('/members_mk_individual/{mk_individual_id}', - response_model=members.Individual, +@app.get('/laws_kns_israel_law/{IsraelLawID}', + response_model=laws.IsraelLaw, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_individual(mk_individual_id: int): - data = DB.get_single_data('members_mk_individual', - 'mk_individual_id', mk_individual_id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_israel_law(IsraelLawID: int): + """Route for single "laws_kns_israel_law" table""" + data = DB.get_single_data('laws_kns_israel_law', + 'IsraelLawID', IsraelLawID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_factions table -@app.get("/members_factions/list", +@app.get("/laws_kns_israel_law_binding/list", status_code=200, - response_model=List[members.Factions], + response_model=List[laws.IsraelLawBinding], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_factions_list( + tags=["laws"]) +async def get_israel_law_binding_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - knessets: List[int] = Query([], alias="knessets", example=[], list=True), + IsraelLawID: Optional[int] = None, + IsraelLawReplacedID: Optional[int] = None, + LawID: Optional[int] = None, + LawTypeID: Optional[int] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_israel_law_binding table""" query_params = request.query_params.items() + order_by = '"IsraelLawBinding" desc' qs_parts = [] - arrays_number_val = [knessets] - arrays_number_names = ["knessets"] for key, value in query_params: - if key in arrays_number_names: - elemts = arrays_number_val[arrays_number_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_factions" + query = "SELECT * FROM laws_kns_israel_law_binding" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for "members_factions" table -@app.get('/members_factions/{id}', - response_model=members.Factions, +@app.get('/laws_kns_israel_law_binding/{IsraelLawBinding}', + response_model=laws.IsraelLawBinding, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_factions(id: int): - data = DB.get_single_data('members_factions', 'id', id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_israel_law_binding(IsraelLawBinding: int): + """Route for single "laws_kns_israel_law_binding" table""" + data = DB.get_single_data('laws_kns_israel_law_binding', + 'IsraelLawBinding', IsraelLawBinding) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list laws_kns_israel_law_classification table -@app.get("/laws_kns_israel_law_classification/list", +@app.get("/laws_kns_israel_law_ministry/list", status_code=200, - response_model=List[laws.IsraelLawClassification], + response_model=List[laws.IsraelLawMinistry], responses={422: errors.LIMIT_ERROR}, tags=["laws"]) -async def get_israel_law_classification_list( +async def get_israel_law_ministry_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, IsraelLawID: Optional[int] = None, - ClassificiationID: Optional[int] = None, - ClassificiationDesc: Optional[str] = None, + GovMinistryID: Optional[int] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_israel_law_ministry table""" query_params = request.query_params.items() + order_by = '"LawMinistryID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM laws_kns_israel_law_classification" + query = "SELECT * FROM laws_kns_israel_law_ministry" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "laws_kns_israel_law_classification" table -@app.get('/laws_kns_israel_law_classification/{LawClassificiationID}', - response_model=laws.IsraelLawClassification, +@app.get('/laws_kns_israel_law_ministry/{LawMinistryID}', + response_model=laws.IsraelLawMinistry, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=["laws"]) -async def get_israel_law_classification(LawClassificiationID: int): - data = DB.get_single_data('laws_kns_israel_law_classification', - 'LawClassificiationID', - LawClassificiationID) +async def get_israel_law_ministry(LawMinistryID: int): + """Route for single "laws_kns_israel_law_ministry" table""" + data = DB.get_single_data('laws_kns_israel_law_ministry', + 'LawMinistryID', LawMinistryID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_mk_individual_names table -@app.get("/members_mk_individual_names/list", +@app.get("/laws_kns_law/list", status_code=200, - response_model=List[members.IndividualNames], + response_model=List[laws.KnsLaw], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_mk_individual_names_list( + tags=["laws"]) +async def get_law_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - names: Optional[str] = None, + TypeID: Optional[int] = None, + TypeDesc: Optional[str] = None, + SubTypeID: Optional[int] = None, + SubTypeDesc: Optional[str] = None, + KnessetNum: Optional[int] = None, + Name: Optional[str] = None, + PublicationDate: Optional[datetime] = None, + PublicationSeriesID: Optional[int] = None, + PublicationSeriesDesc: Optional[str] = None, + MagazineNumber: Optional[str] = None, + PageNumber: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for laws_kns_law table""" query_params = request.query_params.items() + order_by = '"LawID" desc' qs_parts = [] - arrays_val = [[names]] - arrays_name = ["names"] for key, value in query_params: - if key not in ['limit', 'offset', 'order_by'] and \ - key not in arrays_name: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") - for name, val in zip(arrays_name, arrays_val): - if val[0]: - qs_parts.append(f"{name}={val}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual_names" + query = "SELECT * FROM laws_kns_law" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_mk_individual_names" table -@app.get('/members_mk_individual_names/{mk_individual_id}', - response_model=members.IndividualNames, +@app.get('/laws_kns_law/{LawID}', + response_model=laws.KnsLaw, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_individual_names(mk_individual_id: int): - data = DB.get_single_data('members_mk_individual_names', - 'mk_individual_id', - mk_individual_id) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_law(LawID: int): + """Route for single "laws_kns_law" table""" + data = DB.get_single_data('laws_kns_law', 'LawID', LawID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_faction_memberships table -@app.get("/members_faction_memberships/list", +@app.get("/laws_kns_israel_law_name/list", status_code=200, - response_model=List[members.FactionMemberships], + response_model=List[laws.IsraelLawName], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_members_faction_memberships_list( + tags=["laws"]) +async def get_israel_law_name_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - faction_id: Optional[int] = None, - faction_name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - member_mk_ids: List[int] = Query( - [], alias="member_mk_ids", - example=[], - list=True - ), - knesset: Optional[int] = None + IsraelLawID: Optional[int] = None, + LawID: Optional[int] = None, + LawTypeID: Optional[int] = None, + Name: Optional[str] = None, + LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_israel_law_name table""" query_params = request.query_params.items() + order_by = '"IsraelLawNameID" desc' qs_parts = [] - arrays_number_val = [member_mk_ids] - arrays_number_names = ["member_mk_ids"] for key, value in query_params: - if key in arrays_number_names: - elemts = arrays_number_val[arrays_number_names.index(key)] - qs_parts.append(f"{key}={elemts}") - elif key not in ['limit', 'offset', 'order_by']: + if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_faction_memberships" + query = "SELECT * FROM laws_kns_israel_law_name" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_faction_memberships" table -@app.get('/members_faction_memberships/{faction_id}', - response_model=members.FactionMemberships, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_faction_memberships(faction_id: int): - data = DB.get_single_data('members_faction_memberships', - 'faction_id', faction_id) +@app.get('/laws_kns_israel_law_name/{IsraelLawNameID}', + response_model=laws.IsraelLawName, + responses={ + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_israel_law_name(IsraelLawNameID: int): + """Route for single "laws_kns_israel_law_name" table""" + data = DB.get_single_data('laws_kns_israel_law_name', + 'IsraelLawNameID', IsraelLawNameID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_kns_persontoposition table -@app.get("/members_kns_persontoposition/list", +@app.get("/laws_kns_law_binding/list", status_code=200, - response_model=List[members.PersonToPosition], + response_model=List[laws.LawBinding], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_person_to_position_list( + tags=["laws"]) +async def get_law_binding_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - PersonID: Optional[int] = None, - PositionID: Optional[int] = None, - KnessetNum: Optional[int] = None, - GovMinistryID: Optional[int] = None, - GovMinistryName: Optional[str] = None, - DutyDesc: Optional[str] = None, - FactionID: Optional[int] = None, - FactionName: Optional[str] = None, - GovernmentNum: Optional[int] = None, - CommitteeID: Optional[int] = None, - CommitteeName: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - IsCurrent: Optional[bool] = None, + LawID: Optional[int] = None, + LawTypeID: Optional[int] = None, + IsraelLawID: Optional[int] = None, + ParentLawID: Optional[int] = None, + LawParentTypeID: Optional[int] = None, + BindingType: Optional[int] = None, + BindingTypeDesc: Optional[str] = None, + PageNumber: Optional[str] = None, + AmendmentType: Optional[int] = None, + AmendmentTypeDesc: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_law_binding table""" query_params = request.query_params.items() + order_by = '"LawBindingID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_kns_persontoposition" + query = "SELECT * FROM laws_kns_law_binding" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_kns_persontoposition" table -@app.get('/members_kns_persontoposition/{PersonToPositionID}', - response_model=members.PersonToPosition, - responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_persontoposition(PersonToPositionID: int): - data = DB.get_single_data('members_kns_persontoposition', - 'PersonToPositionID', - PersonToPositionID) +@app.get('/laws_kns_law_binding/{LawBindingID}', + response_model=laws.LawBinding, + responses={ + 404: errors.NO_DATA_FOUND_ERROR + }, + tags=["laws"]) +async def get_law_binding(LawBindingID: int): + """Route for single "laws_kns_law_binding" table""" + data = DB.get_single_data('laws_kns_law_binding', + 'LawBindingID', LawBindingID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list committees_kns_committee table -@app.get("/committees_kns_committee/list", +@app.get("/laws_kns_israel_law_classification/list", status_code=200, - response_model=List[committees.KnsCommittee], + response_model=List[laws.IsraelLawClassification], responses={422: errors.LIMIT_ERROR}, - tags=["committees"]) -async def get_committee_list( + tags=["laws"]) +async def get_israel_law_classification_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Name: Optional[str] = None, - CategoryID: Optional[int] = None, - CategoryDesc: Optional[str] = None, - KnessetNum: Optional[int] = None, - CommitteeTypeID: Optional[int] = None, - CommitteeTypeDesc: Optional[str] = None, - Email: Optional[str] = None, - StartDate: Optional[datetime] = None, - FinishDate: Optional[datetime] = None, - AdditionalTypeID: Optional[int] = None, - AdditionalTypeDesc: Optional[str] = None, - ParentCommitteeID: Optional[int] = None, - CommitteeParentName: Optional[str] = None, - IsCurrent: Optional[bool] = None, + IsraelLawID: Optional[int] = None, + ClassificiationID: Optional[int] = None, + ClassificiationDesc: Optional[str] = None, LastUpdatedDate: Optional[datetime] = None ): + """Route for list laws_kns_israel_law_classification table""" query_params = request.query_params.items() + order_by = '"LawClassificiationID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM committees_kns_committee" + query = "SELECT * FROM laws_kns_israel_law_classification" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "committees_kns_committee" table -@app.get('/committees_kns_committee/{CommitteeID}', - response_model=committees.KnsCommittee, +@app.get('/laws_kns_israel_law_classification/{LawClassificiationID}', + response_model=laws.IsraelLawClassification, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["committees"]) -async def get_single_data(CommitteeID: int): - data = DB.get_single_data('committees_kns_committee', - 'CommitteeID', CommitteeID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["laws"]) +async def get_israel_law_classification(LawClassificiationID: int): + """Route for single "laws_kns_israel_law_classification" table""" + data = DB.get_single_data('laws_kns_israel_law_classification', + 'LawClassificiationID', + LawClassificiationID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_mk_individual_factions table -@app.get("/members_mk_individual_factions/list", - status_code=200, - response_model=List[members.IndividualFactions], +@app.get("/lobbyists_v_lobbyist_clients/list", status_code=200, + response_model=List[lobbyists.LobbyistClients], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_mk_individual_factions_list( + tags=["lobbyists"]) +async def get_lobbyist_clients_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - mk_individual_id: Optional[int] = None, - faction_id: Optional[int] = None, - faction_name: Optional[str] = None, - start_date: Optional[date] = None, - finish_date: Optional[date] = None, - knesset: Optional[int] = None + LobbyistID: Optional[int] = None, + ClientID: Optional[int] = None, + Name: Optional[str] = None, + ClientsNames: Optional[str] = None ): + """Route for list lobbyists_v_lobbyist_clients table""" query_params = request.query_params.items() + order_by = '"LobbyistID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_mk_individual_factions" + query = "SELECT * FROM lobbyists_v_lobbyist_clients" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for list members_kns_position table -@app.get("/members_kns_position/list", +@app.get("/lobbyists_v_lobbyist/list", status_code=200, - response_model=List[members.Position], + response_model=List[lobbyists.Lobbyist], responses={422: errors.LIMIT_ERROR}, - tags=["members"]) -async def get_position_list( + tags=["lobbyists"]) +async def get_lobbyist_list( request: Request, limit: int = 100, offset: int = 0, - order_by: Optional[str] = None, - Description: Optional[str] = None, - GenderID: Optional[int] = None, - GenderDesc: Optional[str] = None, - LastUpdatedDate: Optional[datetime] = None + IdentityNumber: Optional[str] = None, + FullName: Optional[str] = None, + PermitTypeValue: Optional[str] = None, + Key: Optional[int] = None, + CorporationName: Optional[str] = None, + IsIndependent: Optional[bool] = None, + CorpNumber: Optional[int] = None, + PracticeFramework: Optional[str] = None, + IsMemberInFaction: Optional[str] = None, + MemberInFaction: Optional[str] = None ): + """Route for lobbyists_v_lobbyist table""" query_params = request.query_params.items() + order_by = '"LobbyistID" desc' qs_parts = [] for key, value in query_params: if key not in ['limit', 'offset', 'order_by']: qs_parts.append(f"{key}={value}") qs = '&'.join(qs_parts) - query = "SELECT * FROM members_kns_position" + query = "SELECT * FROM lobbyists_v_lobbyist" data = DB.get_data_list(query, limit, offset, order_by, qs) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Route for single "members_kns_position" table -@app.get('/members_kns_position/{PositionID}', - response_model=members.Position, +@app.get('/lobbyists_v_lobbyist/{LobbyistID}', + response_model=lobbyists.Lobbyist, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, - tags=["members"]) -async def get_position(PositionID: int): - data = DB.get_single_data('members_kns_position', - 'PositionID', PositionID) + 404: errors.NO_DATA_FOUND_ERROR, + }, + tags=["lobbyists"]) +async def get_lobbyist(LobbyistID: int): + """Route for single "lobbyists_v_lobbyist" table""" + data = DB.get_single_data('lobbyists_v_lobbyist', + 'LobbyistID', LobbyistID) if isinstance(data, TypeError): - response_status = (status.HTTP_404_NOT_FOUND) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + response_status = (status.HTTP_404_NOT_FOUND) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - -# Aggragation @app.get('/minister_by_individual/{id}', status_code=200, response_model=current_minister.MinisterByIndividual, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=['Current ministers'], - description = """ + description=""" Retrieve information about a minister based on their individual ID. - - This route returns data about a minister, including their personal details and legislative history. + + This route returns data about a minister, including their personal + details and legislative history. The keys in the 'data' dictionary provide the following information: - 'mk_individual_id': The unique identifier for the individual minister. @@ -4161,8 +4758,10 @@ async def get_position(PositionID: int): - 'ministers': List of ministerial roles held by the individual. - 'IsChairPerson': Indicates whether the minister is a chairperson (true or false). - 'knessets': List of Knessets (Israeli parliaments) the minister has served in. - - 'committees': List of committees the minister has been associated with (may contain null values). - - 'year_total_hours_attended': A historical record of the minister's yearly hours attended in sessions. + - 'committees': List of committees the minister has been associated + with (may contain null values). + - 'year_total_hours_attended': A historical record of the minister's + yearly hours attended in sessions. You can use this data to gain insights into the minister's political career and activities. """, @@ -4171,13 +4770,14 @@ async def get_position(PositionID: int): status_code=200, response_model=current_minister.MinisterByPersonal, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=['Current ministers'], - description = """ + description=""" Retrieve information about a minister based on their personal ID. - - This route returns data about a minister, including their personal details and legislative history. + + This route returns data about a minister, including their personal + details and legislative history. The keys in the 'data' dictionary provide the following information: - 'PersonID': The unique identifier for the individual minister. @@ -4191,8 +4791,10 @@ async def get_position(PositionID: int): - 'ministers': List of ministerial roles held by the individual. - 'IsChairPerson': Indicates whether the minister is a chairperson (true or false). - 'knessets': List of Knessets (Israeli parliaments) the minister has served in. - - 'committees': List of committees the minister has been associated with (may contain null values). - - 'year_total_hours_attended': A historical record of the minister's yearly hours attended in sessions. + - 'committees': List of committees the minister has been associated + with (may contain null values). + - 'year_total_hours_attended': A historical record of the minister's + yearly hours attended in sessions. You can use this data to gain insights into the minister's political career and activities. """, @@ -4206,23 +4808,27 @@ def get_minister(id: int, request: Request): query = QUERY.get_minister_query(id_field) data = DB.get_fully_today_member(query, (id,)) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data - @app.get('/member_kns_by_individual/{id}', status_code=200, response_model=current_knesset_member.KnessetMemberByIndividual, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=['Current knesset members'], description=""" - Retrieve detailed information about a specific Knesset member based on their unique individual ID. + Retrieve detailed information about a specific Knesset member based + on their unique individual ID. The 'data' dictionary provides the following information: @@ -4234,23 +4840,28 @@ def get_minister(id: int, request: Request): - 'altnames': Alternate names or aliases of the Knesset member. - 'mk_individual_photo': URL to the Knesset member's photo. - 'faction_name': The political faction or party associated with the Knesset member. - - 'IsChairPerson': Indicates whether the Knesset member holds a chairperson position (true or false). + - 'IsChairPerson': Indicates whether the Knesset member holds + a chairperson position (true or false). - 'knessets': List of Knessets (Israeli parliaments) the Knesset member has served in. - - 'committees': List of committees the Knesset member has been associated with, if any. - - 'year_total_hours_attended': A historical record of the Knesset member's yearly hours attended in sessions. + - 'committees': List of committees the Knesset member + has been associated with, if any. + - 'year_total_hours_attended': A historical record of the Knesset member's + yearly hours attended in sessions. - This information provides a comprehensive overview of the Knesset member's political career and activities. + This information provides a comprehensive overview of the Knesset member's + political career and activities. """, summary="Get current member knesset by individual identifier") @app.get('/member_kns_by_personal/{id}', status_code=200, response_model=current_knesset_member.KnessetMemberByPersonal, responses={ - 404: errors.NO_DATA_FOUND_ERROR, - }, + 404: errors.NO_DATA_FOUND_ERROR, + }, tags=['Current knesset members'], description=""" - Retrieve detailed information about a specific Knesset member based on their unique personal ID. + Retrieve detailed information about a specific Knesset member + based on their unique personal ID. The 'data' dictionary provides the following information: @@ -4262,25 +4873,30 @@ def get_minister(id: int, request: Request): - 'altnames': Alternate names or aliases of the Knesset member. - 'mk_individual_photo': URL to the Knesset member's photo. - 'faction_name': The political faction or party associated with the Knesset member. - - 'IsChairPerson': Indicates whether the Knesset member holds a chairperson position (true or false). + - 'IsChairPerson': Indicates whether the Knesset member holds + a chairperson position (true or false). - 'knessets': List of Knessets (Israeli parliaments) the Knesset member has served in. - 'committees': List of committees the Knesset member has been associated with, if any. - - 'year_total_hours_attended': A historical record of the Knesset member's yearly hours attended in sessions. + - 'year_total_hours_attended': A historical record of the Knesset + member's yearly hours attended in sessions. - This information provides a comprehensive overview of the Knesset member's political career and activities. + This information provides a comprehensive overview of the Knesset member's + political career and activities. """, summary="Get current member knesset by personal identifier") def get_member_kns(id: int, request: Request): request_path = request.scope['path'] - id_field = ( - "mk_individual_id" - if request_path == f'/member_kns_by_individual/{str(id)}' else 'PersonID' - ) + id_field = ("mk_individual_id" if request_path == + f'/member_kns_by_individual/{str(id)}' else 'PersonID') query = QUERY.get_member_kns_query(id_field) data = DB.get_fully_today_member(query, (id,)) if isinstance(data, Exception): - response_status = (status.HTTP_404_NOT_FOUND + response_status = (status.HTTP_404_NOT_FOUND if isinstance(data, TypeError) else status.HTTP_422_UNPROCESSABLE_ENTITY) - raise HTTPException(status_code=response_status, detail={'error': type(data).__name__,'msg':str(data)}) + raise HTTPException( + status_code=response_status, + detail={ + 'error': type(data).__name__, + 'msg': str(data)}) return data diff --git a/models/bills.py b/models/bills.py index fe26a64..394cdfd 100644 --- a/models/bills.py +++ b/models/bills.py @@ -1,27 +1,23 @@ +from pydantic import BaseModel from datetime import datetime -from pydantic import BaseModel,Field -from typing import Dict, List, Literal, Optional, Union -from datetime import date -from datetime import time -from datetime import datetime -from decimal import Decimal -from pydantic import EmailStr, HttpUrl +from pydantic import HttpUrl -class KnsBillunion(BaseModel): +class KnsBillUnion(BaseModel): BillUnionID: int = 1 MainBillID: int = 31252 UnionBillID: int = 37664 LastUpdatedDate: datetime = "2015-03-20T12:03:33" -class KnsBillsplit(BaseModel): +class KnsBillSplit(BaseModel): BillSplitID: int = 1 MainBillID: int = 258446 SplitBillID: int = 262881 Name: str = "הצעת חוק אזור סחר חופשי באילת (פטורים והנחות ממסים) (תיקון), התשס\"ח-2007" LastUpdatedDate: datetime = "2015-03-20T12:03:32" + class KnsBillInitiator(BaseModel): BillInitiatorID: int = 1 BillID: int = 29803 @@ -39,6 +35,7 @@ class KnsBillName(BaseModel): NameHistoryTypeDesc: str = "בקריאה הראשונה" LastUpdatedDate: datetime = "2007-06-24T11:51:36" + class KnsDocumentBill(BaseModel): DocumentBillID: int = 75133 BillID: int = 17689 @@ -49,32 +46,34 @@ class KnsDocumentBill(BaseModel): FilePath: HttpUrl = "https://fs.knesset.gov.il//16/law/16_ls_ptk_73614.doc" LastUpdatedDate: datetime = "2010-06-02T21:14:42" + class KnsBillAirflow(BaseModel): BillID: int = 5 KnessetNum: int = 1 - Name: str = "חוק שכר חברי הכנסת, התש\ט-1949" + Name: str = "חוק שכר חברי הכנסת, התש\\ט-1949" SubTypeID: int = 55 SubTypeDesc: str = "ועדה" - PrivateNumber: int | None = 1449 + PrivateNumber: int | None = 1449 CommitteeID: int | None = 377 StatusID: int | None = 118 Number: int | None = 61 - PostponementReasonID : int | None = 2505 + PostponementReasonID: int | None = 2505 PostponementReasonDesc: str | None = 'הסרה מסד"י בד. מוקדם' PublicationDate: datetime | None = "1949-06-07T00:00:00" MagazineNumber: int | None = 10 PageNumber: int | None = 41 IsContinuationBill: bool | None = 'true' SummaryLaw: str | None = ( - 'החוק קובע כי המוסד לביטוח לאומי יפרסם באתר האינטרנט שלו, ' - 'בתחילת כל שנה קלנדרית, את החגים שלפניהם יוקדם תשלום הגמלה לזכאים, ' - 'את הגמלאות שתשלומן יוקדם, ואת המועד שבו תשולם הגמלה לפני החג.' + 'החוק קובע כי המוסד לביטוח לאומי יפרסם באתר האינטרנט שלו, ' + 'בתחילת כל שנה קלנדרית, את החגים שלפניהם יוקדם תשלום הגמלה לזכאים, ' + 'את הגמלאות שתשלומן יוקדם, ואת המועד שבו תשולם הגמלה לפני החג.' ) PublicationSeriesID: int | None = 6071 PublicationSeriesDesc: str | None = "ספר החוקים" PublicationSeriesFirstCall: str | None = 'הצ"ח הכנסת (מתשס"ג 10/2002) - 74 ,מיום 16:00:00' LastUpdatedDate: datetime | None = "2022-11-17T11:08:23" + class KnsBillHistoryInitiator(BaseModel): BillHistoryInitiatorID: int = 1 BillID: int = 403285 @@ -86,13 +85,14 @@ class KnsBillHistoryInitiator(BaseModel): ReasonDesc: str = "חדל להיות חבר כנסת" LastUpdatedDate: datetime = "2015-03-20T12:03:30" + class KnsBill(BaseModel): BillID: int = 5 KnessetNum: int = 1 - Name: str = "חוק שכר חברי הכנסת, התש\ט-1949" + Name: str = "חוק שכר חברי הכנסת, התש\\ט-1949" SubTypeID: int = 55 SubTypeDesc: str = "ועדה" - PrivateNumber: int | None = 1449 + PrivateNumber: int | None = 1449 CommitteeID: int | None = 377 StatusID: int | None = 118 Number: int | None = 61 @@ -102,12 +102,12 @@ class KnsBill(BaseModel): MagazineNumber: int | None = 10 PageNumber: int | None = 41 IsContinuationBill: bool | None = 'true' - SummaryLaw: str | None = ( - 'החוק קובע כי המוסד לביטוח לאומי יפרסם באתר האינטרנט שלו, ' - 'בתחילת כל שנה קלנדרית, את החגים שלפניהם יוקדם תשלום הגמלה לזכאים, ' - 'את הגמלאות שתשלומן יוקדם, ואת המועד שבו תשולם הגמלה לפני החג.' + SummaryLaw: str | None = ( + 'החוק קובע כי המוסד לביטוח לאומי יפרסם באתר האינטרנט שלו, ' + 'בתחילת כל שנה קלנדרית, את החגים שלפניהם יוקדם תשלום הגמלה לזכאים, ' + 'את הגמלאות שתשלומן יוקדם, ואת המועד שבו תשולם הגמלה לפני החג.' ) PublicationSeriesID: int | None = 6071 PublicationSeriesDesc: str | None = "ספר החוקים" PublicationSeriesFirstCall: str | None = 'הצ"ח הכנסת (מתשס"ג 10/2002) - 74 ,מיום 16:00:00' - LastUpdatedDate: datetime | None = "2022-11-17T11:08:23" \ No newline at end of file + LastUpdatedDate: datetime | None = "2022-11-17T11:08:23" diff --git a/models/committees.py b/models/committees.py index 9f9920f..9774c5e 100644 --- a/models/committees.py +++ b/models/committees.py @@ -1,12 +1,10 @@ -from datetime import datetime -from pydantic import BaseModel,Field -from typing import Dict, List, Literal, Optional, Union -from datetime import date -from datetime import time +from pydantic import BaseModel +from typing import Dict, List from datetime import datetime from pydantic import HttpUrl from models.enums.enums import FileType + class KnsDocumentCommitteeSessionDataservice(BaseModel): DocumentCommitteeSessionID: int = 71335 CommitteeSessionID: int = 66045 @@ -17,14 +15,16 @@ class KnsDocumentCommitteeSessionDataservice(BaseModel): FilePath: HttpUrl = "https://fs.knesset.gov.il//16/Committees/16_ptv_71308.doc" LastUpdatedDate: datetime = "2010-06-02T20:32:33" + class KnsJointCommittee(BaseModel): JointCommitteeID: int = 1 CommitteeID: int = 37 ParticipantCommitteeID: int = 21 LastUpdatedDate: datetime = "2015-03-20T12:02:57" + class KnsCommitteeAirflow(BaseModel): - CommitteeID: int = 1 + CommitteeID: int = 1 Name: str = "ועדת הכנסת" CategoryID: int | None = 1 CategoryDesc: str | None = "ועדת הכנסת" @@ -41,6 +41,7 @@ class KnsCommitteeAirflow(BaseModel): IsCurrent: bool = "true" LastUpdatedDate: datetime = "2017-04-24T16:47:06" + class BuildMeetings(BaseModel): CommitteeSessionID: int = 64529 Number: int | None = 460 @@ -58,8 +59,8 @@ class BuildMeetings(BaseModel): protocol_extension: str | None = ".doc" text_filename: str | None = "files/6/4/64529.txt" parts_filename: str | None = "files/6/4/64529.csv" - topics: List[str] | None =[ - "בחירת יושב ראש הוועדה לביקורת המדינה" + topics: List[str] | None = [ + "בחירת יושב ראש הוועדה לביקורת המדינה" ], mks: List[str] = [ " יולי אדלשטיין", @@ -69,10 +70,10 @@ class BuildMeetings(BaseModel): "אתי לבני", "גדעון סער" ] - invitees: List[Dict[str,str]] = [ - {"name":"פרופ' שלמה סלונים"}, - {"name":"פרופ' אריאל בנדור, דיקאן הפקולטה למשפטים, אוניברסיטת חיפה"}, - {"name":"פרופ' זאב סגל, בית הספר לממשל, מדעי החברה, אוניברסיטת תל-אביב"}, + invitees: List[Dict[str, str]] = [ + {"name": "פרופ' שלמה סלונים"}, + {"name": "פרופ' אריאל בנדור, דיקאן הפקולטה למשפטים, אוניברסיטת חיפה"}, + {"name": "פרופ' זאב סגל, בית הספר לממשל, מדעי החברה, אוניברסיטת תל-אביב"}, ] legal_advisors: List[str] = [ " אתי בנדלר", @@ -86,6 +87,7 @@ class BuildMeetings(BaseModel): 61 ] + class DocumentBackgroundMaterialTitles(BaseModel): DocumentCommitteeSessionID: int = 0 CommitteeSessionID: int = 64776 @@ -93,6 +95,7 @@ class DocumentBackgroundMaterialTitles(BaseModel): FilePath: HttpUrl = "https://fs.knesset.gov.il/\\16\\Committees\\16_cs_bg_339777.pdf" title: str = "חומר רקע - חוקי יסוד-1.6.03-רקע" + class JoinedMeetings(BaseModel): CommitteeSessionID: int = 64515 Number: int | None = 2 @@ -114,11 +117,13 @@ class JoinedMeetings(BaseModel): "העסקת קטינות על מסלול הדוגמנות" ] + class KnsCmtSitecode(BaseModel): CmtSiteCode: int = 1 KnsID: int = 1 SiteId: int = 1 + class MeetingProtocolsParts(BaseModel): DocumentCommitteeSessionID: int = 71333 CommitteeSessionID: int = 65782 @@ -135,10 +140,12 @@ class MeetingProtocolsParts(BaseModel): crc32c: str | None = "LLmkqg==" error: str | None = None + class BuildRenderedMeetingsStats(BaseModel): CommitteeSessionID: int = 64529 num_speech_parts: int = 7 + class KnsDocumentCommitteeSession(BaseModel): DocumentCommitteeSessionID: int = 138775 CommitteeSessionID: int = 311813 @@ -156,12 +163,13 @@ class KnsDocumentCommitteeSession(BaseModel): text_parsed_filename: str = "files/3/1/311813.txt" text_filesize: int = 6128 text_crc32c: str = "F0QTJw==" - text_error: str = None + text_error: str = None parts_protocol_extension: str = ".doc" parts_parsed_filename: str = "files/3/1/311813.csv" parts_filesize: int = 6123 parts_crc32c: str = "b/YY6w==" - parts_error: str = None + parts_error: str = None + class KnsCmtSessionItem(BaseModel): CmtSessionItemID: int = 28006 @@ -173,6 +181,7 @@ class KnsCmtSessionItem(BaseModel): ItemTypeID: int | None = 11 LastUpdatedDate: datetime = "2012-09-20T22:23:49" + class KnsCommitteeSession(BaseModel): CommitteeSessionID: int = 64515 Number: int = 460 @@ -194,7 +203,7 @@ class KnsCommitteeSession(BaseModel): parts_filesize: int = 157418 parts_parsed_filename: str = "files/6/4/64516.csv" text_crc32c: str = "l58eRw==" - text_filesize: int= 157991 + text_filesize: int = 157991 text_parsed_filename: str = "files/6/4/64516.txt" item_ids: List[int] = [ 74814, @@ -205,7 +214,7 @@ class KnsCommitteeSession(BaseModel): 74811, 74810 ] - item_type_ids: List[int] = [ + item_type_ids: List[int] = [ 11, 11, 11, @@ -215,14 +224,13 @@ class KnsCommitteeSession(BaseModel): 11 ] topics: List[str] = [ - "שינויים בתקציב לשנת 2003", - "בחירת יו\"ר לועדה הזמנית", - "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", - "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)" - ] + "שינויים בתקציב לשנת 2003", + "בחירת יו\"ר לועדה הזמנית", + "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", + "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)"] committee_name: str = "ועדת החוץ והביטחון" bill_names: List[str] = [ "חוק הגנה על עובדים בשעת חירום (הוראת שעה), התשס\"ג-2003" @@ -244,6 +252,7 @@ class DocumentCommitteeSessionsParsing(BaseModel): LastUpdatedDate: datetime = "2010-06-02T20:32:33" KnessetNum: int = 16 + class DownloadDocumentCommitteeSession(BaseModel): DocumentCommitteeSessionID: int = 71333 CommitteeSessionID: int = 65782 @@ -259,6 +268,7 @@ class DownloadDocumentCommitteeSession(BaseModel): crc32c: str | None = "UqP16Q==" error: str | None = None + class MeetingProtocolsText(BaseModel): DocumentCommitteeSessionID: int = 71333 CommitteeSessionID: int = 65782 @@ -269,12 +279,13 @@ class MeetingProtocolsText(BaseModel): FilePath: HttpUrl | None = "http://fs.knesset.gov.il//16/Committees/16_ptv_71307.doc" LastUpdatedDate: datetime = "2010-06-02T20:32:33" KnessetNum: int | None = 16 - protocol_extension: str | None= ".doc" - parsed_filename: str | None= "files/6/5/65782.txt" + protocol_extension: str | None = ".doc" + parsed_filename: str | None = "files/6/5/65782.txt" filesize: int | None = 82413 crc32c: str | None = "56WyDA==" error: str | None = None + class KnsCommittee(BaseModel): CommitteeID: int = 1 Name: str = "ועדת הכנסת" @@ -292,9 +303,3 @@ class KnsCommittee(BaseModel): CommitteeParentName: str | None = "ועדת החקירה בנושא איתור והשבת נכסים של נספי השואה" IsCurrent: bool = "true" LastUpdatedDate: datetime = "2017-04-24T16:47:06" - - - - - - diff --git a/models/current_knesset_member.py b/models/current_knesset_member.py index dad31b5..0a8f5ad 100644 --- a/models/current_knesset_member.py +++ b/models/current_knesset_member.py @@ -1,36 +1,44 @@ from pydantic import BaseModel from typing import List, Union + class KnessetMemberByIndividual(BaseModel): mk_individual_id: int = 214 FirstName: str = "אביגדור" LastName: str = "ליברמן" GenderDesc: str = "זכר" - Email: str | None = "aliberman@knesset.gov.il" + Email: str | None = "aliberman@knesset.gov.il" altnames: List[str] = ["אביגדור ליברמן"] mk_individual_photo: str | None = "https://oknesset.org/static/img/Male_portrait_placeholder_cropped.jpg" + mk_individual_photo: str | None = "https://oknesset.org/static/img/Male_portrait_placeholder_cropped.jpg" faction_name: str = "ישראל ביתנו בראשות אביגדור ליברמן" IsChairPerson: bool = True knessets: str = "15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25" - committees: List[Union[None, str]] = ["הוועדה לפיקוח על הקרן לאזרחי ישראל (חבר ועדה)", - "ועדת הכלכלה (חבר ועדה)", - "ועדת המשנה לקידום תעשיית ההייטק (חבר ועדה)", - "ועדת המשנה לקידום תעשיית ההייטק (יו\"ר ועדה)"] - year_total_hours_attended: str = "[2010-86,2011-219,2012-185,2013-1252,2014-270,2015-699,2016-586,2019-437,2020-688,2021-434,2022-222,2023-818]" + committees: List[Union[None, + str]] = ["הוועדה לפיקוח על הקרן לאזרחי ישראל (חבר ועדה)", + "ועדת הכלכלה (חבר ועדה)", + "ועדת המשנה לקידום תעשיית ההייטק (חבר ועדה)", + "ועדת המשנה לקידום תעשיית ההייטק (יו\"ר ועדה)"] + year_total_hours_attended: str = "[2010-86,2011-219,2012-185,2013-1252,2014-270,2015-699,2016-586,2019-437,2020-688,2021-434,2022-222,2023-818]" + class KnessetMemberByPersonal(BaseModel): + PersonID: int = 427 PersonID: int = 427 FirstName: str = "אביגדור" LastName: str = "ליברמן" GenderDesc: str = "זכר" Email: str | None = "aliberman@knesset.gov.il" + Email: str | None = "aliberman@knesset.gov.il" altnames: List[str] = ["אביגדור ליברמן"] mk_individual_photo: str | None = "https://oknesset.org/static/img/Male_portrait_placeholder_cropped.jpg" + mk_individual_photo: str | None = "https://oknesset.org/static/img/Male_portrait_placeholder_cropped.jpg" faction_name: str = "ישראל ביתנו בראשות אביגדור ליברמן" IsChairPerson: bool = True knessets: str = "15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25" - committees: List[Union[None, str]] = ["הוועדה לפיקוח על הקרן לאזרחי ישראל (חבר ועדה)", - "ועדת הכלכלה (חבר ועדה)", - "ועדת המשנה לקידום תעשיית ההייטק (חבר ועדה)", - "ועדת המשנה לקידום תעשיית ההייטק (יו\"ר ועדה)"] - year_total_hours_attended: str = "[2010-86,2011-219,2012-185,2013-1252,2014-270,2015-699,2016-586,2019-437,2020-688,2021-434,2022-222,2023-818]" + committees: List[Union[None, + str]] = ["הוועדה לפיקוח על הקרן לאזרחי ישראל (חבר ועדה)", + "ועדת הכלכלה (חבר ועדה)", + "ועדת המשנה לקידום תעשיית ההייטק (חבר ועדה)", + "ועדת המשנה לקידום תעשיית ההייטק (יו\"ר ועדה)"] + year_total_hours_attended: str = "[2010-86,2011-219,2012-185,2013-1252,2014-270,2015-699,2016-586,2019-437,2020-688,2021-434,2022-222,2023-818]" diff --git a/models/current_minister.py b/models/current_minister.py index b16c371..1076c33 100644 --- a/models/current_minister.py +++ b/models/current_minister.py @@ -1,6 +1,7 @@ from pydantic import BaseModel, validator, ValidationError from typing import List, Union + class MinisterByIndividual(BaseModel): mk_individual_id: int = 69 FirstName: str = "ישראל" @@ -15,8 +16,10 @@ class MinisterByIndividual(BaseModel): knessets: str = "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25" committees: List[Union[None, str]] = [None] year_total_hours_attended: str = "[2010-72, 2011-193, 2012-148, 2013-308, 2014-276, 2015-384, 2016-388, 2017-297, 2018-182, 2019-71, 2020-205, 2021-518, 2022-335, 2023-399]" - + + class MinisterByPersonal(BaseModel): + PersonID: int = 468 PersonID: int = 468 FirstName: str = "ישראל" LastName: str = "כץ" @@ -29,5 +32,4 @@ class MinisterByPersonal(BaseModel): IsChairPerson: bool = True knessets: str = "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25" committees: List[Union[None, str]] = [None] - year_total_hours_attended: str = "[2010-72, 2011-193, 2012-148, 2013-308, 2014-276, 2015-384, 2016-388, 2017-297, 2018-182, 2019-71, 2020-205, 2021-518, 2022-335, 2023-399]" - + year_total_hours_attended: str = "[2010-72, 2011-193, 2012-148, 2013-308, 2014-276, 2015-384, 2016-388, 2017-297, 2018-182, 2019-71, 2020-205, 2021-518, 2022-335, 2023-399]" diff --git a/models/enums/enums.py b/models/enums/enums.py index db027fd..39397ee 100644 --- a/models/enums/enums.py +++ b/models/enums/enums.py @@ -1,6 +1,6 @@ from enum import Enum -#Used in votes.py + class ResultTypeNameEnum(str, Enum): CANCELED = "בוטל" APPROVED = "בעד" @@ -8,6 +8,7 @@ class ResultTypeNameEnum(str, Enum): ABSTAINED = "נמנע" DID_NOT_VOTE = "לא הצביע" + class ResultTypeIDEnum(int, Enum): CANCELED = 0 APPROVED = 1 @@ -15,7 +16,7 @@ class ResultTypeIDEnum(int, Enum): ABSTAINED = 3 DID_NOT_VOTE = 4 -#Used in plenum.py, laws.py + class FileType(Enum): URL = "URL" PIC = "PIC" @@ -23,4 +24,3 @@ class FileType(Enum): VDO = "VDO" PPT = "PPT" DOC = "DOC" - diff --git a/models/knesset.py b/models/knesset.py index 0ccf08b..436a37a 100644 --- a/models/knesset.py +++ b/models/knesset.py @@ -1,13 +1,14 @@ -from datetime import datetime from pydantic import BaseModel from datetime import datetime + class KnsGovministry(BaseModel): GovMinistryID: int = 490 - Name: str = "אין נתונים" + Name: str = "אין נתונים" IsActive: bool = 'false' LastUpdatedDate: datetime = "2019-12-31T14:45:32" + class KnsKnessetDates(BaseModel): KnessetDateID: int = 1 KnessetNum: int = 13 @@ -18,6 +19,7 @@ class KnsKnessetDates(BaseModel): PlenumFinish: datetime | None = "1993-03-24T00:00:00" IsCurrent: bool = 'false' + class KnsStatus(BaseModel): StatusID: int = 6 Desc: str = "בטיפול המשרד הנשאל" @@ -27,8 +29,8 @@ class KnsStatus(BaseModel): IsActive: bool | None = 'true' LastUpdatedDate: datetime = "2013-10-06T14:08:19" + class KnsItemtype(BaseModel): ItemTypeID: int = 1 Desc: str = "שאילתה" TableName: str | None = "KNS_Query" - \ No newline at end of file diff --git a/models/laws.py b/models/laws.py index b531dd0..22f9859 100644 --- a/models/laws.py +++ b/models/laws.py @@ -1,4 +1,3 @@ -from datetime import datetime from pydantic import BaseModel from datetime import datetime from models.enums.enums import FileType @@ -15,6 +14,7 @@ class DocumentLaw(BaseModel): FilePath: HttpUrl = "https://fs.knesset.gov.il//2/law/2_lsr_311000.PDF" LastUpdatedDate: datetime = "2015-06-29T15:31:18" + class IsraelLaw(BaseModel): IsraelLawID: int = 2000001 KnessetNum: int = 1 @@ -26,26 +26,29 @@ class IsraelLaw(BaseModel): LatestPublicationDate: datetime | None = "1960-07-29T00:00:00" LawValidityID: int | None = 6079 LawValidityDesc: str | None = "תקף" - ValidityStartDate: datetime | None = "1959-04-19T00:00:00" + ValidityStartDate: datetime | None = "1959-04-19T00:00:00" ValidityStartDateNotes: str | None = "תחילתו של חוק זה ביום שתיכון הממשלה לאחר הבחירות לכנסת השש עשרה" - ValidityFinishDate: datetime | None = "1969-04-14T00:00:00" + ValidityFinishDate: datetime | None = "1969-04-14T00:00:00" ValidityFinishDateNotes: str | None = "כל הפקודה הוחלפה על-ידי חוק העונשין למעט סעיף 38 לפקודה שנותר בתוקף" LastUpdatedDate: datetime | None = "2015-06-29T15:31:18" + class IsraelLawBinding(BaseModel): - IsraelLawBinding:int = 1 - IsraelLawID:int = 2002363 - IsraelLawReplacedID:int = 2001409 + IsraelLawBinding: int = 1 + IsraelLawID: int = 2002363 + IsraelLawReplacedID: int = 2001409 LawID: int = 569596 LawTypeID: int = 2 LastUpdatedDate: datetime = "2016-05-25T14:10:03" + class IsraelLawMinistry(BaseModel): LawMinistryID: int = 2135419 IsraelLawID: int = 2000001 GovMinistryID: int = 16 LastUpdatedDate: datetime = "2014-09-10T14:27:17" + class KnsLaw(BaseModel): LawID: int = 2001427 TypeID: int = 6002 @@ -53,13 +56,14 @@ class KnsLaw(BaseModel): SubTypeID: int = 6043 SubTypeDesc: str = "מנדטורי" KnessetNum: int | None = 4 - Name: str| None = "דבר המלך על הטיס במושבות (הטלת חוקים), 1937" - PublicationDate: datetime| None = "1937-07-29T00:00:00" - PublicationSeriesID: int| None = 6078 - PublicationSeriesDesc: str| None = "עיתון רשמי מנדטורי" - MagazineNumber: str| None = "תוס' 2 - 707" - PageNumber: str| None = "תוס' 2 - 707" - LastUpdatedDate: datetime| None = "2019-07-02T09:42:20" + Name: str | None = "דבר המלך על הטיס במושבות (הטלת חוקים), 1937" + PublicationDate: datetime | None = "1937-07-29T00:00:00" + PublicationSeriesID: int | None = 6078 + PublicationSeriesDesc: str | None = "עיתון רשמי מנדטורי" + MagazineNumber: str | None = "תוס' 2 - 707" + PageNumber: str | None = "תוס' 2 - 707" + LastUpdatedDate: datetime | None = "2019-07-02T09:42:20" + class IsraelLawName(BaseModel): IsraelLawNameID: int = 1 @@ -69,6 +73,7 @@ class IsraelLawName(BaseModel): Name: str = "חוק רשות הפיתוח (העברת נכסים), התש\"י-1950" LastUpdatedDate: datetime = "2016-05-09T15:40:21" + class LawBinding(BaseModel): LawBindingID: int = 41555 LawID: int = 148560 @@ -83,12 +88,10 @@ class LawBinding(BaseModel): AmendmentTypeDesc: str = "ישיר" LastUpdatedDate: datetime = "2014-09-10T14:27:13" + class IsraelLawClassification(BaseModel): LawClassificiationID: int = 1 IsraelLawID: int = 2000001 ClassificiationID: int = 23 ClassificiationDesc: str = "מקרקעין" LastUpdatedDate: datetime = "2015-01-15T15:59:55" - - - diff --git a/models/lobbyists.py b/models/lobbyists.py index 2593170..20ed0f9 100644 --- a/models/lobbyists.py +++ b/models/lobbyists.py @@ -8,15 +8,16 @@ class LobbyistClients(BaseModel): Name: str = "Abbvie" ClientsNames: str = "Abbvie- ייצוג קבוע" + class Lobbyist(BaseModel): LobbyistID: int = 879 IdentityNumber: str = "029723319" - FullName: str = "אביב ברנט" - PermitTypeValue: str = "שדלן זמני" + FullName: str = "אביב ברנט" + PermitTypeValue: str = "שדלן זמני" Key: Decimal = "2.0" CorporationName: str = "שדלן עצמאי" IsIndependent: bool = 'true' CorpNumber: Decimal = "512065194.0" PracticeFramework: str | None = "תאגידים / גופים אחרים" IsMemberInFaction: str | None = 'הליכוד' - MemberInFaction: bool = 'true' \ No newline at end of file + MemberInFaction: bool = 'true' diff --git a/models/members.py b/models/members.py index 8e1c305..19e4934 100644 --- a/models/members.py +++ b/models/members.py @@ -1,10 +1,10 @@ -from datetime import datetime from pydantic import BaseModel from typing import List, Literal from datetime import date as dt from datetime import datetime from pydantic import HttpUrl + class FactionChairpersons(BaseModel): mk_individual_id: int = 915 faction_id: int = 1102 @@ -13,6 +13,7 @@ class FactionChairpersons(BaseModel): finish_date: dt | None = '24/10/23' knesset: int = 25 + class Govministries(BaseModel): mk_individual_id: int = 915 govministry_id: int = 1 @@ -23,16 +24,18 @@ class Govministries(BaseModel): finish_date: dt | None = '24/10/23' knesset: int = 25 + class MembersPresence(BaseModel): mk_id: int = 790 mk_name: str = "יצחק אהרונוביץ'" - date: dt= "05/07/10" + date: dt = "05/07/10" year: int = 2010 month: int = 7 day: int = 5 year_week_number: int = 27 total_attended_hours: int = 8 - + + class Committees(BaseModel): mk_individual_id: int = 1097 committee_id: int = 4228 @@ -43,6 +46,7 @@ class Committees(BaseModel): finish_date: dt | None = "23/10/21" knesset: int = 25 + class PersonAirflow(BaseModel): PersonID: int = 405 LastName: str = "ליברמן" @@ -59,6 +63,7 @@ class Mksitecode(BaseModel): KnsID: int = 405 SiteId: int = 12 + class Person(BaseModel): PersonID: int = 405 LastName: str = "ליברמן" @@ -69,6 +74,7 @@ class Person(BaseModel): IsCurrent: bool = 'true' LastUpdatedDate: datetime = "2015-03-20T12:03:08" + class Individual(BaseModel): mk_individual_id: int = 214 mk_status_id: int = 0 @@ -87,65 +93,69 @@ class Individual(BaseModel): IsCurrent: bool = 'true' LastUpdatedDate: datetime = "2022-11-10T11:19:09" altnames: List[str] = [ - "אביגדור ליברמן" + "אביגדור ליברמן" ] + class Factions(BaseModel): id: int = 1082 name: str = "דגל התורה" start_date: dt = "15/08/22" finish_date: dt | None = "15/11/22" knessets: List[int] = [ - 24 + 24 ] + class IndividualNames(BaseModel): mk_individual_id: int = 209 names: List[str] = [ - "אליעזר כהן" + "אליעזר כהן" ] + class FactionMemberships(BaseModel): faction_id: int = 1096 faction_name: str = "סיעת הליכוד " start_date: dt = "16/10/23" finish_date: dt | None = "10/12/23" member_mk_ids: List[int] = [ - 1, - 771, - 914, - 921, - 30772, - 953, - 826, - 828, - 69, - 1095, - 1098, - 1100, - 1101, - 974, - 976, - 1105, - 723, - 1109, - 1111, - 30809, - 90, - 987, - 1116, - 992, - 1122, - 1123, - 1124, - 1125, - 1002, - 1011, - 30711, - 1018 + 1, + 771, + 914, + 921, + 30772, + 953, + 826, + 828, + 69, + 1095, + 1098, + 1100, + 1101, + 974, + 976, + 1105, + 723, + 1109, + 1111, + 30809, + 90, + 987, + 1116, + 992, + 1122, + 1123, + 1124, + 1125, + 1002, + 1011, + 30711, + 1018 ] knesset: int = 25 + class PersonToPosition(BaseModel): PersonToPositionID: int = 379 PersonID: int = 2605 @@ -164,6 +174,7 @@ class PersonToPosition(BaseModel): IsCurrent: bool = 'false' LastUpdatedDate: datetime = "2015-03-20T12:03:08" + class IndividualFactions(BaseModel): mk_individual_id: int = 30809 faction_id: int = 1096 @@ -172,11 +183,10 @@ class IndividualFactions(BaseModel): finish_date: dt | None = "15/10/21" knesset: int = 23 + class Position(BaseModel): PositionID: int = 29 Description: str = "יושבת–ראש הקואליציה" GenderID: int = 250 GenderDesc: Literal['זכר', 'נקבה'] = "נקבה" LastUpdatedDate: datetime = "2015-03-20T12:03:00" - - diff --git a/models/people.py b/models/people.py index 27d2fe0..b075c6d 100644 --- a/models/people.py +++ b/models/people.py @@ -1,9 +1,9 @@ -from datetime import datetime from pydantic import BaseModel from typing import Dict, List, Literal, Union from datetime import datetime from pydantic import HttpUrl + class PlenumSessionVotersStats(BaseModel): knesset: int = 16 plenum: int = 1 @@ -15,9 +15,10 @@ class PlenumSessionVotersStats(BaseModel): total_sessions: int = 10 voted_sessions_percent: int = 0 + class CommitteesJoinedMeetings(BaseModel): CommitteeSessionID: int = 64516 - Number: int = 2 + Number: int | None = 2 KnessetNum: int = 16 TypeID: int = 161 TypeDesc: str = "פתוחה" @@ -31,19 +32,19 @@ class CommitteesJoinedMeetings(BaseModel): LastUpdatedDate: datetime = "2012-09-19T15:27:32" text_file_name: str | None = "data/committees/meeting_protocols_text/files/6/4/64529.txt" text_file_size: int | None = 482 - topics: List[str] = [ - "שינויים בתקציב לשנת 2003", - "בחירת יו\"ר לועדה הזמנית", - "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", - "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)" - ] + topics: List[str] | None = [ + "שינויים בתקציב לשנת 2003", + "בחירת יו\"ר לועדה הזמנית", + "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", + "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)"] + class CommitteesMeetingAttendees(BaseModel): CommitteeSessionID: int = 64516 - Number: int = 2 + Number: int | None = 2 KnessetNum: int = 16 TypeID: int = 161 TypeDesc: str = "פתוחה" @@ -65,33 +66,33 @@ class CommitteesMeetingAttendees(BaseModel): text_filesize: int | None = 157991 text_parsed_filename: str | None = "files/6/4/64516.txt" item_ids: List[int] | None = [ - 74814, - 74813, - 73285, - 73284, - 74812, - 74811, - 74810 + 74814, + 74813, + 73285, + 73284, + 74812, + 74811, + 74810 ], item_type_ids: List[int] | None = [ - 11, - 11, - 11, - 11, - 11, - 11, - 11 + 11, + 11, + 11, + 11, + 11, + 11, + 11 ], topics: List[str] | None = [ - "שינויים בתקציב לשנת 2003", - "בחירת יו\"ר לועדה הזמנית", - "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", - "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", - "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", - "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)" + "שינויים בתקציב לשנת 2003", + "בחירת יו\"ר לועדה הזמנית", + "תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\"ג - 2003", + "תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\"ג - 2003", + "צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\"ג - 2003 (פסיפס מקרמיקה וזכוכית)", + "צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\"ג - 2002 (דגים שנדוגו ע\"י ספינות דייג ישראליות)" ], - committee_name: str | None = "ועדת הכספים" + committee_name: str | None = "ועדת הכספים" bill_names: List[str] = [ "חוק שירות המילואים, התשס\"ח-2008", "הצעת חוק המילואים, התשס\"ו-2006" @@ -102,37 +103,38 @@ class CommitteesMeetingAttendees(BaseModel): ] related_to_legislation: bool | None = 'true' mks: List[str] | None = [ - "ישראל כץ - היו\"ר", - "רוחמה אברהם", - "זבולון אורלב", - "אברהם בייגה שוחט", - "שלום שמחון" + "ישראל כץ - היו\"ר", + "רוחמה אברהם", + "זבולון אורלב", + "אברהם בייגה שוחט", + "שלום שמחון" ], invitees: List[Dict[str, str]] | None = [ - { - "name": "אורטל מינקוביץ-ראש ענף פיקוח תקציבי, החשב הכללי, משרד האוצר" - }, - { - "name": "גיא אבן-רפרנט שיכון, אגף התקציבים, משרד האוצר" - }, + { + "name": "אורטל מינקוביץ-ראש ענף פיקוח תקציבי, החשב הכללי, משרד האוצר" + }, + { + "name": "גיא אבן-רפרנט שיכון, אגף התקציבים, משרד האוצר" + }, ] legal_advisors: List[str] | None = [ - "שגית אפיק", - "אנה שניידר", - "מירב אלבז (מתמחה)" + "שגית אפיק", + "אנה שניידר", + "מירב אלבז (מתמחה)" ] manager: List[str] | None = [ - "טמיר כהן" + "טמיר כהן" ] financial_advisors: List[str] | None = [ - "סמדר אלחנני" + "סמדר אלחנני" ] attended_mk_individual_ids: List[int] = [ - 64, - 123, - 92 + 64, + 123, + 92 ] + class PartyDisciplineStats(BaseModel): knesset: int = 16 plenum: int = 2 @@ -146,6 +148,7 @@ class PartyDisciplineStats(BaseModel): undisciplined_votes_percent: int = 0 disciplined_votes_percent: int = 11 + class CommitteesMeetingAttendeesMksFullStats(BaseModel): knesset: int = 16 plenum: int = 1 @@ -160,6 +163,7 @@ class CommitteesMeetingAttendeesMksFullStats(BaseModel): attended_meetings_percent: int = 0 attended_meetings_relative_percent: int = 0 + class CommitteesMeetingSpeakerStats(BaseModel): CommitteeSessionID: int = 100017 parts_crc32c: str = "EIzyDg==" @@ -172,9 +176,10 @@ class CommitteesMeetingSpeakerStats(BaseModel): mk_individual_id: int = 1 mk_individual_faction: str = 'התאחדות הספרדים שומרי תורה - תנועת ש"ס' + class PlenumSessionVoters(BaseModel): PlenumSessionID: int = 9626 - Number: int = 1 + Number: int | None = 1 KnessetNum: int = 16 Name: str = "ישיבת מליאה בתאריך 17/02/2003 בשעה: 16:00" StartDate: datetime = "2003-02-17T16:00:00" @@ -182,9 +187,10 @@ class PlenumSessionVoters(BaseModel): IsSpecialMeeting: bool = "false" LastUpdatedDate: datetime = "2013-10-03T16:21:47" voter_mk_ids: List[int] | None = [ - 65,3,100,197,36,5,13,206,208,752,756,757,727,732 + 65, 3, 100, 197, 36, 5, 13, 206, 208, 752, 756, 757, 727, 732 ] + class MkVotedAgainstMajority(BaseModel): vote_id: int = 10 mk_id: int = 114 @@ -197,6 +203,7 @@ class MkVotedAgainstMajority(BaseModel): vote_majority: str = 'against' voted_against_majority: bool = 'false' + class MkPartyDisciplineKnesset20(BaseModel): vote_id: int = 31582 vote_url: HttpUrl = 'http://www.knesset.gov.il/vote/heb/Vote_Res_Map.asp?vote_id_t=31582' @@ -211,18 +218,20 @@ class MkPartyDisciplineKnesset20(BaseModel): faction_name: str = 'יש עתיד' vote_majority: str = 'pro' + class CommitteesMeetingAttendeesMksStats(BaseModel): knesset_num: int = 16 committee_id: int = 21 committee_name: str = 'ועדת הכספים' meeting_start_date: datetime = '2003-02-24T10:00:00' - meeting_topics: str = "'שינויים בתקציב לשנת 2003, בחירת יו\ר לועדה הזמנית, תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\ג - 2003, תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\ג - 2003, צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\ג - 2003, צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\ג - 2003 (פסיפס מקרמיקה וזכוכית), צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\ג - 2002 (דגים שנדוגו ע\י ספינות דייג ישראליות)" + meeting_topics: str = "'שינויים בתקציב לשנת 2003, בחירת יו\\ר לועדה הזמנית, תקנות התקשורת (בזק ושידורים)(חישוב תשלומים בעד שירותי בזק והצמדתם)(תיקון), התשס\\ג - 2003, תקנות התקשורת (בזק ושידורים)(תשלומים בעד שירותי בזק המפורטים בתוספת לחוק)(תיקון מס' 2), התשס\\ג - 2003, צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 115), התשס\\ג - 2003, צו תעריף המכס והפטורים ומס קניה על טובין (הוראת שעה)(מס' 3), התשס\\ג - 2003 (פסיפס מקרמיקה וזכוכית), צו תעריף המכס והפטורים ומס קניה על טובין (תיקון מס' 110), התשס\\ג - 2002 (דגים שנדוגו ע\\י ספינות דייג ישראליות)" mk_id: int = 64 mk_name: str = 'איתן כבל' mk_membership_committee_names: str = 'ועדת הכספים, ועדת הפנים ואיכות הסביבה' mk_faction_id: int = 24 mk_faction_name: str = 'הליכוד' + class MembersJoinedMks(BaseModel): mk_individual_id: int = 1 mk_status_id: int = 1 @@ -236,51 +245,52 @@ class MembersJoinedMks(BaseModel): LastName: str = 'אדלשטיין' FirstName: str = 'יולי יואל' GenderID: int = 251 - GenderDesc: Literal['זכר','נקבה'] = 'זכר' + GenderDesc: Literal['זכר', 'נקבה'] = 'זכר' Email: str | None = 'yedelstein@knesset.gov.il' IsCurrent: bool = 'true' LastUpdatedDate: datetime = '2015-11-15T19:51:25' positions: List[Dict[str, Union[str, int, datetime]]] = [ - { - 'gender':'m', - 'position': 'סגן יו\ר הכנסת', - 'KnessetNum': 15, - 'start_date': '1999-09-14 00:00:00', - 'finish_date': '2001-03-12 00:00:00', - 'position_id': 70 - }, - { - 'gender':'m', - 'DutyDesc': 'שר ההסברה והתפוצות', - 'position':'שר', - 'KnessetNum': 18, - 'start_date':'2009-03-31 00:00:00', - 'finish_date': '2013-02-05 00:00:00', - 'position_id': 39, - 'GovMinistryID': 137, - 'GovernmentNum': 32, - 'GovMinistryName': 'ההסברה' - }, - { - 'gender': 'm', - 'position': 'חבר ועדה', - 'KnessetNum': 16, - 'start_date': '2003-02-17 00:00:00', - 'CommitteeID': 72, - 'finish_date': '2006-04-17 00:00:00', - 'position_id': 42, - 'CommitteeName': 'לתיקונים בחוקי הבחירות' - } + { + 'gender': 'm', + 'position': 'סגן יו\\ר הכנסת', + 'KnessetNum': 15, + 'start_date': '1999-09-14 00:00:00', + 'finish_date': '2001-03-12 00:00:00', + 'position_id': 70 + }, + { + 'gender': 'm', + 'DutyDesc': 'שר ההסברה והתפוצות', + 'position': 'שר', + 'KnessetNum': 18, + 'start_date': '2009-03-31 00:00:00', + 'finish_date': '2013-02-05 00:00:00', + 'position_id': 39, + 'GovMinistryID': 137, + 'GovernmentNum': 32, + 'GovMinistryName': 'ההסברה' + }, + { + 'gender': 'm', + 'position': 'חבר ועדה', + 'KnessetNum': 16, + 'start_date': '2003-02-17 00:00:00', + 'CommitteeID': 72, + 'finish_date': '2006-04-17 00:00:00', + 'position_id': 42, + 'CommitteeName': 'לתיקונים בחוקי הבחירות' + } ] altnames: List[str] = [ - 'יואל אדלשטין', - 'יואל יולי אדלשטיין', - 'יולי אדלשטין', - 'יולי יואל אדלשטיין', - 'יואל אדלשטיין', - 'יולי - יואל אדלשטיין' + 'יואל אדלשטין', + 'יואל יולי אדלשטיין', + 'יולי אדלשטין', + 'יולי יואל אדלשטיין', + 'יואל אדלשטיין', + 'יולי - יואל אדלשטיין' ] + class CommitteesMeetingAttendeesMks(BaseModel): CommitteeSessionID: int = 64529 Number: int | None = 67 @@ -299,7 +309,7 @@ class CommitteesMeetingAttendeesMks(BaseModel): text_filename: str | None = 'files/6/4/64529.txt' parts_filename: str | None = 'files/6/4/64529.csv' topics: List[str] | None = [ - 'בחירת יושב ראש הוועדה לביקורת המדינה' + 'בחירת יושב ראש הוועדה לביקורת המדינה' ], mks: List[str] = [ " יולי אדלשטיין", @@ -310,9 +320,9 @@ class CommitteesMeetingAttendeesMks(BaseModel): "גדעון סער" ] invitees: List[Dict[str, str]] = [ - {"name":"פרופ' שלמה סלונים"}, - {"name":"פרופ' אריאל בנדור, דיקאן הפקולטה למשפטים, אוניברסיטת חיפה"}, - {"name":"פרופ' זאב סגל, בית הספר לממשל, מדעי החברה, אוניברסיטת תל-אביב"} + {"name": "פרופ' שלמה סלונים"}, + {"name": "פרופ' אריאל בנדור, דיקאן הפקולטה למשפטים, אוניברסיטת חיפה"}, + {"name": "פרופ' זאב סגל, בית הספר לממשל, מדעי החברה, אוניברסיטת תל-אביב"} ] legal_advisors: List[str] = [ " אתי בנדלר", @@ -320,4 +330,4 @@ class CommitteesMeetingAttendeesMks(BaseModel): ] manager: List[str] = [ "דורית ואג" - ] \ No newline at end of file + ] diff --git a/models/plenum.py b/models/plenum.py index 85713dc..4ab8dfc 100644 --- a/models/plenum.py +++ b/models/plenum.py @@ -1,8 +1,8 @@ -from datetime import datetime from pydantic import BaseModel from datetime import datetime from models.enums.enums import FileType + class DocumentPlenumSession(BaseModel): DocumentPlenumSessionID: int = 128869 PlenumSessionID: int = 129232 @@ -10,18 +10,20 @@ class DocumentPlenumSession(BaseModel): GroupTypeDesc: str = "תוכן עניינים" ApplicationID: int = 1 ApplicationDesc: FileType = "DOC" - FilePath: str = "https://fs.knesset.gov.il//16/Plenum/16_toc_128869.DOC" + FilePath: str = "https://fs.knesset.gov.il//16/Plenum/16_toc_128869.DOC" LastUpdatedDate: datetime = "2010-06-03T06:55:10" + class PlenumSession(BaseModel): PlenumSessionID: int = 9626 - Number: int = 1 - KnessetNum: int = 16 + Number: int = 1 + KnessetNum: int = 16 Name: str = "ישיבת מליאה בתאריך 17/02/2003 בשעה 16:00" - StartDate: datetime = "2003-02-17T16:00:00" + StartDate: datetime = "2003-02-17T16:00:00" FinishDate: datetime | None = "2003-02-17T17:03:00" IsSpecialMeeting: bool = 'false' - LastUpdatedDate: datetime = "2023-07-06T12:45:23" + LastUpdatedDate: datetime = "2023-07-06T12:45:23" + class PlmSessionItem(BaseModel): plmPlenumSessionID: int = 3365 @@ -33,5 +35,4 @@ class PlmSessionItem(BaseModel): Name: str = "דברים לזכרם של חברי הכנסת לשעבר שמעון גרידי ודוד שטרן, זכרונם לברכה" StatusID: int | None = 305 IsDiscussion: int = 1 - LastUpdatedDate: datetime = "2023-07-06T12:45:23" - \ No newline at end of file + LastUpdatedDate: datetime = "2023-07-06T12:45:23" diff --git a/models/user_friendly.py b/models/user_friendly.py index badfc80..b27388b 100644 --- a/models/user_friendly.py +++ b/models/user_friendly.py @@ -4,6 +4,7 @@ from datetime import date as dt from datetime import time + class Member(BaseModel): mk_individual_id: int = 14 mk_individual_first_name: str = "זאב בנימין" @@ -12,118 +13,123 @@ class Member(BaseModel): GenderID: int = 251 GenderDesc: str = "זכר" IsCurrent: bool = "false" - mk_individual_email: str| None = None + mk_individual_email: str | None = None altnames: List[str] = [ - "זאב בנימין בגין", - "בינימין בגין", - "בנימין בגין" - ] - committee_positions: List[Dict[str, Union[int, str, dt, None]]] | List[None] = [ - { - "mk_individual_id": 14, - "committee_id": 932, - "committee_name": "ועדת החוקה, חוק ומשפט", - "position_id": 42, - "position_name": "חבר ועדה", - "start_date": "2015-06-01", - "finish_date": "2019-04-30", - "knesset": 20 - } + "זאב בנימין בגין", + "בינימין בגין", + "בנימין בגין" ] - factions: List[Dict[str, Union[int, str, dt, None]]] | List[None]= [ - { - "mk_individual_id": 14, - "faction_id": 882, - "faction_name": "הליכוד", - "start_date": "2015-03-31", - "finish_date": "2019-04-30", - "knesset": 20 - } + committee_positions: List[Dict[str, + Union[int, + str, + dt, + None]]] | List[None] = [{"mk_individual_id": 14, + "committee_id": 932, + "committee_name": "ועדת החוקה, חוק ומשפט", + "position_id": 42, + "position_name": "חבר ועדה", + "start_date": "2015-06-01", + "finish_date": "2019-04-30", + "knesset": 20}] + factions: List[Dict[str, Union[int, str, dt, None]]] | List[None] = [ + { + "mk_individual_id": 14, + "faction_id": 882, + "faction_name": "הליכוד", + "start_date": "2015-03-31", + "finish_date": "2019-04-30", + "knesset": 20 + } ] - faction_chairpersons: List[Dict[str, Union[int, str, dt, None]]] | List[None]= [ - { - "faction_name":"סיעת יהדות התורה", - "finish_date":"2023-01-23", - "knesset":25, - "mk_individual_id":35, - "faction_id":1101, - "start_date":"2022-11-15" - } + faction_chairpersons: List[Dict[str, Union[int, str, dt, None]]] | List[None] = [ + { + "faction_name": "סיעת יהדות התורה", + "finish_date": "2023-01-23", + "knesset": 25, + "mk_individual_id": 35, + "faction_id": 1101, + "start_date": "2022-11-15" + } ] - govministries: List[Dict[str, Union[int, str, dt, None]]] | List[None]= [ - { - "mk_individual_id": 14, - "govministry_id": 28, - "govministry_name": "משרד ראש הממשלה", - "position_id": 39, - "position_name": "שר", - "start_date": "2015-05-14", - "finish_date": "2015-06-01", - "knesset": 20 - } + govministries: List[Dict[str, Union[int, str, dt, None]]] | List[None] = [ + { + "mk_individual_id": 14, + "govministry_id": 28, + "govministry_name": "משרד ראש הממשלה", + "position_id": 39, + "position_name": "שר", + "start_date": "2015-05-14", + "finish_date": "2015-06-01", + "knesset": 20 + } ] + + class MemberAttendedCommitteeMeetings(BaseModel): CommitteeSessionID: int = 64541 KnessetNum: int = 16 TypeID: int = 161 TypeDesc: str = "פתוחה" CommitteeID: int = 26 - Location: str | None= "חדר הוועדה, באגף הוועדות (קדמה), קומה 1, חדר 1750", + Location: str | None = "חדר הוועדה, באגף הוועדות (קדמה), קומה 1, חדר 1750", SessionUrl: HttpUrl = "http://main.knesset.gov.il/Activity/committees/Pages/AllCommitteesAgenda.aspx?Tab=3&ItemID=64541", - BroadcastUrl: HttpUrl| None = "http://main.knesset.gov.il/Activity/committees/Pages/AllCommitteesBroadcast.aspx?TopicID=1576" + BroadcastUrl: HttpUrl | None = "http://main.knesset.gov.il/Activity/committees/Pages/AllCommitteesBroadcast.aspx?TopicID=1576" StartDate: datetime = "2003-03-24T12:00:00" - FinishDate: datetime| None = "2003-03-24T23:59:00" + FinishDate: datetime | None = "2003-03-24T23:59:00" Note: str | None = "חדר הוועדה, קומה 2-, באגף החדש" - topics: List[str]| None =[ - "בחירת יושב ראש הוועדה לביקורת המדינה" + topics: List[str] | None = [ + "בחירת יושב ראש הוועדה לביקורת המדינה" ] committee_name: str = "ועדת העלייה, הקליטה והתפוצות" bill_names: List[str] = [ - "חוק המדיניות הכלכלית לשנת הכספים 2004 (תיקוני חקיקה), התשס\"ד-2004" + "חוק המדיניות הכלכלית לשנת הכספים 2004 (תיקוני חקיקה), התשס\"ד-2004" ] bill_types: List[str] = [ - "ממשלתית" + "ממשלתית" ] related_to_legislation: bool = 'false' + class MemberVote(BaseModel): - knesset_num: int = 16 - session_id: int = 15797 - sess_item_id: int = 16060 - sess_item_dscr: str | None = "הודעת ראש הממשלה על פעילות הממשלה בתקופה שחלפה ועל תוכניותיה למושב הקרוב" - vote_item_id: int = 905 - vote_item_dscr: str | None = "הצעת סיכום" - vote_date: dt = "2003-10-20" + knesset_num: int = 16 + session_id: int = 15797 + sess_item_id: int = 16060 + sess_item_dscr: str | None = "הודעת ראש הממשלה על פעילות הממשלה בתקופה שחלפה ועל תוכניותיה למושב הקרוב" + vote_item_id: int = 905 + vote_item_dscr: str | None = "הצעת סיכום" + vote_date: dt = "2003-10-20" vote_time: time | None = "20:08" - is_elctrnc_vote: int = 1 - is_accepted: int = 0 - total_for: int = 13 - total_against: int = 54 - total_abstain: int = 11 + is_elctrnc_vote: int = 1 + is_accepted: int = 0 + total_for: int = 13 + total_against: int = 54 + total_abstain: int = 11 mk_vote: str = "abstain" + class MemberBill(BaseModel): BillID: int = 86915 KnessetNum: int = 16 Name: str = "חוק שוויון זכויות לאנשים עם מוגבלות (תיקון מס' 2), התשס\"ה-2005" SubTypeID: Optional[int] = 54 SubTypeDesc: Optional[str] = "פרטית" - PrivateNumber: Optional[int] = 775 - CommitteeID: Optional[int] = 28 - StatusID: Optional[int] = 118 - Number: Optional[int] = 2951 - PostponementReasonID: Optional[int] = None + PrivateNumber: Optional[int] = 775 + CommitteeID: Optional[int] = 28 + StatusID: Optional[int] = 118 + Number: Optional[int] = 2951 + PostponementReasonID: Optional[int] = None PostponementReasonDesc: Optional[str] = None PublicationDate: Optional[datetime] = "2005-04-07T00:00:00" - MagazineNumber: Optional[int] = 1995 - PageNumber: Optional[int] = 288 + MagazineNumber: Optional[int] = 1995 + PageNumber: Optional[int] = 288 IsContinuationBill: Optional[bool] = True SummaryLaw: Optional[str] = None - PublicationSeriesID: Optional[int] = 6071 - PublicationSeriesDesc: Optional[str] = "ספר החוקים" + PublicationSeriesID: Optional[int] = 6071 + PublicationSeriesDesc: Optional[str] = "ספר החוקים" PublicationSeriesFirstCall: Optional[str] = None IsInitiator: Optional[bool] = True + class MemberPresence(BaseModel): mk_id: int = 214 mk_name: str = "אביגדור ליברמן" @@ -132,4 +138,8 @@ class MemberPresence(BaseModel): month: int = 1 day: int = 1 year_week_number: int = 1 - total_attended_hours : int = 7 + total_attended_hours: int = 7 + + +class MkIndividualIDs(BaseModel): + mk_individual_id: int diff --git a/models/votes.py b/models/votes.py index 508d3ef..68e8145 100644 --- a/models/votes.py +++ b/models/votes.py @@ -1,10 +1,10 @@ - from pydantic import BaseModel from typing import List from datetime import date as dt from datetime import time from models.enums.enums import ResultTypeNameEnum, ResultTypeIDEnum + class ViewVoteRsltsHdrApproved(BaseModel): id: int = 8 knesset_num: int = 16 @@ -29,6 +29,7 @@ class ViewVoteRsltsHdrApproved(BaseModel): modifier: str = "Unknown" remark: str | None = "הצעתו של חבר הכנסת אפי איתם" + class VoteRsltsKmmbrShadowExtra(BaseModel): vote_id: int = 94 kmmbr_id: str = "000000405" @@ -43,6 +44,7 @@ class VoteRsltsKmmbrShadowExtra(BaseModel): result_type_name: str = "בעד" mk_individual_id: int = 12 + class ViewVoteMkIndividual(BaseModel): vip_id: str = "000000405" mk_individual_id: int = 12 @@ -51,6 +53,7 @@ class ViewVoteMkIndividual(BaseModel): mk_individual_first_name: str = "בנימין" mk_individual_first_name_eng: str = "Benyamin" + class VoteRsltsKmmbrShadow(BaseModel): vote_id: int = 94 kmmbr_id: str = "000000405" @@ -88,39 +91,40 @@ class ViewVoteRsltsHdrApprovedExtra(BaseModel): modifier: str = "Unknown" remark: str | None = "הצעתו של חבר הכנסת אפי איתם" mk_ids_pro: List[int] = [ - 704, - 137, - 104, - 201, - 126, - 197, - 218, - 13, - 36, - 29, - 208, - 697, - 756 + 704, + 137, + 104, + 201, + 126, + 197, + 218, + 13, + 36, + 29, + 208, + 697, + 756 ] mk_ids_against: List[int] = [ - 209, - 751, - 3, - 92 + 209, + 751, + 3, + 92 ] mk_ids_abstain: List[int] = [ - 220, - 100, - 115, - 65, - 739, - 5 + 220, + 100, + 115, + 65, + 739, + 5 ] knesset: int = 16 plenum: int = 2 assembly: int = 1 pagra: bool = "false" + class VoteResultType(BaseModel): result_type_id: ResultTypeIDEnum = ResultTypeIDEnum.CANCELED result_type_name: ResultTypeNameEnum = ResultTypeNameEnum.CANCELED