Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
81958c3d
Commit
81958c3d
authored
Feb 02, 2021
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented reddit schema prototype
parent
548b0855
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
223 additions
and
0 deletions
+223
-0
add_smart_reddit_schema.py
...p/_add_use_case_scripts/reddit/add_smart_reddit_schema.py
+37
-0
add_reddit_posts.py
...p/_add_use_case_scripts/reddit/tables/add_reddit_posts.py
+133
-0
add_reddit_users.py
...p/_add_use_case_scripts/reddit/tables/add_reddit_users.py
+53
-0
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/reddit/add_smart_reddit_schema.py
0 → 100644
View file @
81958c3d
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
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/reddit/tables/add_reddit_posts.py
0 → 100644
View file @
81958c3d
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
)
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/reddit/tables/add_reddit_users.py
0 → 100644
View file @
81958c3d
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment