async def import_topic(topic: Topic): result = get_topic_by_id(topic.topicId) if result is None: # import_topic_to_db(topic) create_topic_schema(topic) else: update_topic_schema(topic.topicId, topic)
def create_raw_topic(code, data, current_user): topic = Topic() topic.topicId = get_surrogate_key() topic.tenantId = current_user.tenantId topic.name = code topic.type = "raw" topic.factors = [] queue = deque([]) if type(data) == list: for record in data: model: dict = {"root": record} queue.append(model) create_factors(queue, topic) create_topic_schema(topic)
async def save_topic(topic: Topic, current_user: User = Depends(deps.get_current_user)): if check_fake_id(topic.topicId): result = create_topic_schema(topic) create_or_update_presto_schema_fields(result) return result else: topic = Topic.parse_obj(topic) data = update_topic_schema(topic.topicId, topic) create_or_update_presto_schema_fields(data) return data
def create_raw_topic_v3(code, data, current_user): topic = Topic() topic.topicId = get_surrogate_key() topic.tenantId = current_user.tenantId topic.name = code topic.type = "raw" topic.factors = [] queue = deque([]) rs = Relationship() if type(data) == list: for record in data: model: dict = {"root": record} queue.append(model) create_factors(queue, topic, rs) mp = rs.get_mapping() parent = [] child = mp.get("root", []) generate_surrogate_key("root", parent, child, mp, topic) create_topic_schema(topic) else: raise ValueError("the data must be array")
async def create_topic(topic: Topic, current_user: User = Depends(deps.get_current_user)): return create_topic_schema(topic)