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
dc6fbe8e
Commit
dc6fbe8e
authored
May 03, 2021
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Participation] added community prediction youtube schema
parent
2cacde05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
193 additions
and
0 deletions
+193
-0
add_schema.py
...e_case_scripts/community-prediction/youtube/add_schema.py
+40
-0
add_table.py
..._scripts/community-prediction/youtube/tables/add_table.py
+153
-0
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/community-prediction/youtube/add_schema.py
0 → 100644
View file @
dc6fbe8e
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_table
as
add_table
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__"
:
# TODO strategy pattern for all the use cases where add_use_case() etc. is clear duplicate code
# The same for add table, where almost everything is the same (UniqueId, Timestamp for every Layer)
# Only need to get jwt token once in the strategy impl
use_case
=
"community-prediction-youtube"
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
add_use_case
(
use_case
)
add_table
.
main
(
use_case
=
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/community-prediction/youtube/tables/add_table.py
0 → 100644
View file @
dc6fbe8e
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
import
requests
def
add_table
(
use_case
:
str
,
table_name
:
str
):
''' Adds the use-case table with all the mappings as dict Internal -> External. '''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
mapping
=
{
c
:
c
for
c
in
[
# mapping does not change any of the names for these properties
'trending_date'
,
'title'
,
'channel_title'
,
'category_id'
,
'category_name'
,
'publish_time'
,
'tags'
,
'views'
,
'likes'
,
'dislikes'
,
'comment_count'
,
'comments_disabled'
,
'ratings_disabled'
,
'video_error_or_removed'
,
'country_code'
,
'country_id'
,
'publish_timestamp'
,
]
}
mapping
[
"UniqueID"
]
=
"video_id"
mapping
[
"trend_delay"
]
=
"trend_duration"
mapping
[
"timestamp"
]
=
"trending_timestamp"
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
table
=
{
"name"
:
table_name
,
"mappings"
:
mapping
}
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
table
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
add_layers
(
use_case
:
str
,
table_name
:
str
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
layers
=
[
{
"name"
:
"CategoryLayer"
,
"properties"
:
[
"UniqueID"
,
"category_id"
,
"category_name"
,
],
"cluster_properties"
:
[
"category_id"
]
},
{
"name"
:
"ViewsLayer"
,
"properties"
:
[
"UniqueID"
,
"views"
,
],
"cluster_properties"
:
[
"views"
]
},
{
"name"
:
"LikesLayer"
,
"properties"
:
[
"UniqueID"
,
"likes"
,
],
"cluster_properties"
:
[
"likes"
]
},
{
"name"
:
"DislikesLayer"
,
"properties"
:
[
"UniqueID"
,
"dislikes"
,
],
"cluster_properties"
:
[
"dislikes"
]
},
{
"name"
:
"CommentCountLayer"
,
"properties"
:
[
"UniqueID"
,
"comment_count"
,
],
"cluster_properties"
:
[
"comment_count"
]
},
{
"name"
:
"CountryLayer"
,
"properties"
:
[
"UniqueID"
,
"country_code"
,
"country_id"
,
],
"cluster_properties"
:
[
"country_id"
]
},
{
"name"
:
"TrendDelayLayer"
,
"properties"
:
[
"UniqueID"
,
"trend_delay"
,
],
"cluster_properties"
:
[
"trend_delay"
]
},
]
for
layer
in
layers
:
# add basic info to each layer
layer
[
"use_case"
]
=
use_case
layer
[
"table"
]
=
table_name
layer
[
"properties"
]
.
append
(
"timestamp"
)
url
=
f
"https://articonf1.itec.aau.at:30420/api/layers"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
layer
)
print
(
url
+
": "
+
str
(
response
.
status_code
))
def
main
(
use_case
:
str
,
table_name
:
str
=
"community-prediction-youtube"
):
add_table
(
use_case
,
table_name
)
add_layers
(
use_case
,
table_name
)
\ No newline at end of file
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