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
666cb120
Commit
666cb120
authored
Apr 12, 2021
by
Manuel Herold
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feature/pull-video-data' into feature/enums
parents
e60b011f
ba7a3462
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
210 additions
and
2 deletions
+210
-2
add_vialog_schema.py
...ice/app/_add_use_case_scripts/vialog/add_vialog_schema.py
+2
-2
add_vialog_schema_new.py
...app/_add_use_case_scripts/vialog/add_vialog_schema_new.py
+41
-0
add_change.py
...ice/app/_add_use_case_scripts/vialog/tables/add_change.py
+60
-0
pull_video_data.py
src/rest-gateway/app/pull_video_data.py
+107
-0
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/vialog/add_vialog_schema.py
View file @
666cb120
...
...
@@ -9,7 +9,7 @@ for modules_path in modules_paths:
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
from
_add_use_case_scripts.vialog.tables
import
add_user
,
add_video
from
_add_use_case_scripts.vialog.tables
import
add_user
,
add_video
,
add_change
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
...
...
@@ -38,4 +38,4 @@ if __name__ == "__main__":
add_use_case
(
use_case
)
add_user
.
main
(
use_case
)
add_video
.
main
(
use_case
)
\ No newline at end of file
add_change
.
main
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/vialog/add_vialog_schema_new.py
0 → 100644
View file @
666cb120
import
sys
import
os
from
pathlib
import
Path
from
typing
import
Dict
,
Any
import
requests
modules_paths
=
[
'.'
,
'../../../modules/'
]
for
modules_path
in
modules_paths
:
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
from
_add_use_case_scripts.vialog.tables
import
add_user
,
add_video
,
add_change
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
def
add_use_case
(
use_case
:
str
):
#use_case = "vialog"
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
.
content
))
if
__name__
==
"__main__"
:
use_case
=
"vialog-new"
# disable ssl warnings :)
requests
.
packages
.
urllib3
.
disable_warnings
()
add_use_case
(
use_case
)
add_user
.
main
(
use_case
)
add_video
.
main
(
use_case
)
add_change
.
main
(
use_case
)
\ No newline at end of file
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/vialog/tables/add_change.py
0 → 100644
View file @
666cb120
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
=
[
"changeType"
,
"changedValue"
,
"previousValue"
,
"newValue"
,
]
columns
=
{
c
:
c
for
c
in
columns
}
columns
[
"UniqueID"
]
=
"videoId+changeId"
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"
:
"Changetype_Layer"
,
"properties"
:
[
"changeType"
,
],
"cluster_properties"
:
[
"changeType"
,
]
},
{
"use_case"
:
use_case
,
"table"
:
table_name
,
"name"
:
"Changedvalue_Layer"
,
"properties"
:
[
"changedValue"
,
"previousValue"
,
"newValue"
],
"cluster_properties"
:
[
"changedValue"
]
}
]
postLayersToSwagger
(
use_case
,
layers
)
def
main
(
use_case
:
str
):
print
(
"user"
)
table_name
=
"change"
add_table
(
use_case
,
table_name
)
add_layers
(
use_case
,
table_name
)
\ No newline at end of file
src/rest-gateway/app/pull_video_data.py
0 → 100644
View file @
666cb120
import
requests
import
json
videoListUrl
=
"https://dev758755.vialog.app/Videos/Meta/ListAll"
videoUrl
=
"https://dev758755.vialog.app/stat/events?type=video&id="
# token from Rest Gateway to authorize
JWT_TOKEN
=
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InJlZ3VsYXJAaXRlYy5hYXUuYXQiLCJjcmVhdGVkX2F0IjoiMjAyMS0wNC0wNyAxMjo0OTo0MS43MTkzNjQiLCJ2YWxpZF91bnRpbCI6IjIwMjEtMDQtMDggMTI6NDk6NDEuNzE5MzY0In0.FN6qqBQeJSmXtS0-0dBiL-ojz6Ou7E5Tc9macrrhM4A'
def
send_transaction_to_rest_gateway
(
transaction
:
dict
):
res
=
requests
.
post
(
url
=
'https://articonf1.itec.aau.at:30401/api/trace'
,
json
=
transaction
,
headers
=
{
"Authorization"
:
f
"Bearer {JWT_TOKEN}"
},
verify
=
False
# ignore ssl error
)
print
(
res
)
videosRequest
=
requests
.
get
(
videoListUrl
)
empty
=
set
()
html
=
set
()
if
(
videosRequest
.
status_code
!=
200
):
print
(
f
"Status: {videosRequest.status_code}"
)
dataCount
=
0
for
video
in
videosRequest
.
json
():
dataCount
+=
1
id
=
video
[
"videoId"
]
videoRequest
=
requests
.
get
(
f
"{videoUrl}{id}"
)
if
videoRequest
.
status_code
!=
200
:
print
(
f
"Status: {videoRequest.status_code}"
)
if
videoRequest
.
text
!=
""
and
not
videoRequest
.
text
.
startswith
(
"<!DOCTYPE html>"
):
print
(
f
"
\n\n
{videoUrl}{id}
\n
{videoRequest.text}"
)
historyList
=
sorted
(
videoRequest
.
json
()[
0
][
"History"
],
key
=
lambda
k
:
k
[
'moderationDate'
],
reverse
=
True
)
historyList
.
append
(
empty
)
i
=
0
changeList
=
[]
for
eventMap
in
historyList
:
if
historyList
[
i
+
1
]
==
empty
:
break
if
i
==
0
:
lastState
=
eventMap
lastState
[
"AppicationType"
]
=
"vialog-new"
lastState
[
"docType"
]
=
"video"
#send_transaction_to_rest_gateway(lastState)
print
(
lastState
)
if
eventMap
[
"eventName"
]
==
'r1eabcbdc8f5378b2ba71a1b6fe2038b Created'
or
eventMap
[
"eventName"
]
==
'Created'
:
change
=
{
"changeType"
:
"Created"
,
"changedValue"
:
"video_state"
,
"previousValue"
:
""
,
"newValue"
:
"Created"
}
elif
eventMap
[
"eventName"
]
==
"Restore"
:
change
=
{
"changeType"
:
"Restore"
,
"changedValue"
:
""
,
"previousValue"
:
""
,
"newValue"
:
""
}
elif
eventMap
[
"eventName"
]
==
"PositionChange"
:
change
=
{
"changeType"
:
"PositionChange"
,
"changedValue"
:
"position"
,
"previousValue"
:
historyList
[
i
+
1
][
"position"
],
"newValue"
:
eventMap
[
"position"
]}
elif
eventMap
[
"eventName"
]
==
"Hide"
:
change
=
{
"changeType"
:
"Hide"
,
"changedValue"
:
"video_state"
,
"previousValue"
:
historyList
[
i
+
1
][
"video_state"
],
"newValue"
:
eventMap
[
"video_state"
]}
elif
eventMap
[
"eventName"
]
==
"Publish"
:
change
=
{
"changeType"
:
"Publish"
,
"changedValue"
:
"video_state"
,
"previousValue"
:
historyList
[
i
+
1
][
"video_state"
],
"newValue"
:
eventMap
[
"video_state"
]}
elif
eventMap
[
"eventName"
]
==
"CMNote"
:
change
=
{
"changeType"
:
"CMNote"
,
"changedValue"
:
"communityManagerNotes"
,
"previousValue"
:
historyList
[
i
+
1
][
"communityManagerNotes"
],
"newValue"
:
eventMap
[
"communityManagerNotes"
]}
elif
eventMap
[
"eventName"
]
==
"Move"
:
change
=
{
"changeType"
:
"Move"
,
"changedValue"
:
"position"
,
"previousValue"
:
historyList
[
i
+
1
][
"position"
],
"newValue"
:
eventMap
[
"position"
]}
elif
eventMap
[
"eventName"
]
==
"VideoType"
:
change
=
{
"changeType"
:
"VideoType"
,
"changedValue"
:
"video_type"
,
"previousValue"
:
historyList
[
i
+
1
][
"video_type"
],
"newValue"
:
eventMap
[
"video_type"
]}
elif
eventMap
[
"eventName"
]
==
"Delete"
:
change
=
{
"changeType"
:
"Delete"
,
"changedValue"
:
""
,
"previousValue"
:
""
,
"newValue"
:
""
}
elif
eventMap
[
"eventName"
]
==
"Copy"
:
change
=
{
"changeType"
:
"Copy"
,
"changedValue"
:
""
,
"previousValue"
:
""
,
"newValue"
:
""
}
elif
eventMap
[
"eventName"
]
==
"CustomLabel"
:
change
=
{
"changeType"
:
"CustomLabel"
,
"changedValue"
:
"label"
,
"previousValue"
:
historyList
[
i
+
1
][
"label"
],
"newValue"
:
eventMap
[
"label"
]}
change
[
"videoId"
]
=
id
change
[
"changeId"
]
=
i
change
[
"timestamp"
]
=
eventMap
[
"moderationDate"
]
change
[
"ApplicationType"
]
=
"vialog-new"
change
[
"docType"
]
=
"change"
print
(
change
)
send_transaction_to_rest_gateway
(
change
)
i
+=
1
elif
videoRequest
.
text
==
""
:
empty
.
add
(
id
)
else
:
html
.
add
(
id
)
print
(
f
"empty: {empty}
\n\n
"
)
print
(
f
"html page: {html}
\n\n
"
)
print
(
f
"history: {historyList}"
)
print
(
dataCount
)
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