def _business_logic(request_data: dict) -> list: # By this point, our award_id has been validated and cleaned up by # TinyShield. We will either have an internal award id that is an # integer or a generated award id that is a string. award_id = request_data["award_id"] award_id_column = "id" if type(award_id) is int else "generated_unique_award_id" sql = FUNDING_SQL.format( award_id_column=Identifier(award_id_column), award_id=Literal(award_id), order_by=build_composable_order_by(SORTABLE_COLUMNS[request_data["sort"]], request_data["order"]), limit=Literal(request_data["limit"] + 1), offset=Literal((request_data["page"] - 1) * request_data["limit"]), ) return execute_sql_to_ordered_dictionary(sql)
def _business_logic(request_data: dict) -> list: # By this point, our award_id has been validated and cleaned up by # TinyShield. We will either have an internal award id that is an # integer or a generated award id that is a string. award_id = request_data['award_id'] award_id_column = 'award_id' if type(award_id) is int else 'generated_unique_award_id' sql = GET_FUNDING_SQL.format( award_id_column=Identifier(award_id_column), award_id=Literal(award_id), piid=Literal(request_data.get('piid')), order_by=build_composable_order_by(SORTABLE_COLUMNS[request_data['sort']], request_data['order']), limit=Literal(request_data['limit'] + 1), offset=Literal((request_data['page'] - 1) * request_data['limit']), ) return execute_sql_to_ordered_dictionary(sql)
def _business_logic(request_data: dict) -> list: # By this point, our award_id has been validated and cleaned up by # TinyShield. We will either have an internal award id that is an # integer or a generated award id that is a string. award_id = request_data['award_id'] award_id_column = 'award_id' if type(award_id) is int else 'generated_unique_award_id' sql = GET_FUNDING_SQL.format( award_id_column=Identifier(award_id_column), award_id=Literal(award_id), piid=Literal(request_data.get('piid')), order_by=build_composable_order_by(SORTABLE_COLUMNS[request_data['sort']], request_data['order']), limit=Literal(request_data['limit'] + 1), offset=Literal((request_data['page'] - 1) * request_data['limit']), ) return execute_sql_to_ordered_dictionary(sql)
def _build_composable_order_by(*args, **kwargs): result = build_composable_order_by(*args, **kwargs) return result.as_string(cursor.connection)
def _build_composable_order_by(*args, **kwargs): result = build_composable_order_by(*args, **kwargs) return result.as_string(cursor.connection)