Commit 81958c3d authored by Bogdan's avatar Bogdan

Implemented reddit schema prototype

parent 548b0855
import sys
import os
from pathlib import Path
from typing import Dict, Any
import requests
modules_path = '../../../modules/'
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
import network_constants as nc
from security.token_manager import TokenManager
import tables.add_reddit as reddit
def add_use_case(use_case: str):
jwt = TokenManager.getInstance().getToken()
url = f"https://articonf1.itec.aau.at:30420/api/use-cases"
response = requests.post(
url,
verify=False,
proxies = { "http":None, "https":None },
headers = { "Authorization": f"Bearer {jwt}"},
json = {"name": use_case}
)
print(url+": "+str(response.status_code))
if __name__ == "__main__":
use_case = "reddit"
# disable ssl warnings :)
requests.packages.urllib3.disable_warnings()
add_use_case(use_case)
reddit.main(use_case)
\ No newline at end of file
from _add_use_case_scripts.requestPost import postLayersToSwagger, postTableToSwagger
def add_table(use_case: str, table_name: str):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
columns = {}
columns["UniqueID"] = "posts//subreddit+//posts//id"
columns["subreddit"] = "posts/subreddit"
columns["user_id"] = "posts//user_id"
columns["title"] = "posts//title"
columns["content"] = "posts//content"
columns["permalink]"] = "posts//permalink"
columns["upvotes"] = "posts//upvotes"
columns["percentage_upvoted"] = "posts//percentage_upvoted"
columns["n_comments"] = "posts//n_comments"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "Subreddit_Layer",
"properties": [
"UniqueID",
"subreddit",
"user_id",
"title",
"content",
"permalink",
"upvotes",
"percentage_upvoted",
"n_comments"
],
"cluster_properties": [
"subreddit"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "User_Post_Layer",
"properties": [
"UniqueID",
"subreddit",
"user_id",
"title",
"content",
"permalink",
"upvotes",
"percentage_upvoted",
"n_comments"
],
"cluster_properties": [
"user_id"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Upvotes_Layer", #TODO Probably do something like Total Votes? so we can get a popularity?
"properties": [
"UniqueID",
"subreddit",
"user_id",
"title",
"content",
"permalink",
"upvotes",
"percentage_upvoted",
"n_comments"
],
"cluster_properties": [
"upvotes"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Liked_Layer",
"properties": [
"UniqueID",
"subreddit",
"user_id",
"title",
"content",
"permalink",
"upvotes",
"percentage_upvoted",
"n_comments"
],
"cluster_properties": [
"percentage_upvoted"
]
},
{
"use_case": use_case,
"table": table_name,
"name": "Engagement_Layer",
"properties": [
"UniqueID",
"subreddit",
"user_id",
"title",
"content",
"permalink",
"upvotes",
"percentage_upvoted",
"n_comments"
],
"cluster_properties": [
"n_comments"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("posts")
table_name = "posts"
add_table(use_case,table_name)
add_layers(use_case,table_name)
from _add_use_case_scripts.requestPost import postLayersToSwagger, postTableToSwagger
def add_table(use_case: str, table_name: str):
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
columns = {}
columns["UniqueID"] = "users//id"
columns["name"] = "users//id"
#TODO should it have some other attributes from posts// ????
# columns["subreddit"] = "posts/subreddit"
# columns["user_id"] = "posts//user_id"
# columns["title"] = "posts//title"
# columns["content"] = "posts//content"
# columns["permalink]"] = "posts//permalink"
# columns["upvotes"] = "posts//upvotes"
# columns["percentage_upvoted"] = "posts//percentage_upvoted"
# columns["n_comments"] = "posts//n_comments"
table = {
"name": table_name,
"mappings": columns
}
postTableToSwagger(use_case,table)
def add_layers(use_case:str, table_name: str):
layers = [
{
"use_case": use_case,
"table": table_name,
"name": "Name_Layer",
"properties": [
"UniqueID",
"name"
],
"cluster_properties": [
"name"
]
}
]
postLayersToSwagger(use_case,layers)
def main(use_case: str):
print("users")
table_name = "users"
add_table(use_case,table_name)
add_layers(use_case,table_name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment