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
c38ae421
Commit
c38ae421
authored
Feb 04, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added db entities
parent
fe2835b5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
0 deletions
+74
-0
__init__.py
...munity-detection-microservice/app/db/entities/__init__.py
+3
-0
location.py
...munity-detection-microservice/app/db/entities/location.py
+29
-0
popular_location.py
...etection-microservice/app/db/entities/popular_location.py
+19
-0
user_cluster.py
...ty-detection-microservice/app/db/entities/user_cluster.py
+23
-0
No files found.
src/data-hub/community-detection-microservice/app/db/entities/__init__.py
0 → 100644
View file @
c38ae421
from
db.entities.location
import
Location
from
db.entities.popular_location
import
PopularLocation
from
db.entities.user_cluster
import
UserCluster
\ No newline at end of file
src/data-hub/community-detection-microservice/app/db/entities/location.py
0 → 100644
View file @
c38ae421
import
json
from
datetime
import
datetime
class
Location
:
def
__init__
(
self
,
location_info
=
None
):
super
()
.
__init__
()
if
location_info
is
not
None
:
self
.
latitude
=
float
(
location_info
[
'latitude'
])
self
.
longitude
=
float
(
location_info
[
'longitude'
])
self
.
timestamp
=
datetime
.
fromtimestamp
(
location_info
[
'timestamp'
])
self
.
timestamp_raw
=
location_info
[
'timestamp'
]
self
.
user
=
location_info
[
'user'
]
self
.
id
=
f
'{self.user}-{self.timestamp_raw}'
def
to_serializable_dict
(
self
):
return
{
"id"
:
self
.
id
,
"latitude"
:
self
.
latitude
,
"longitude"
:
self
.
longitude
,
"timestamp"
:
self
.
timestamp_raw
,
"user"
:
self
.
user
}
def
__repr__
(
self
):
return
json
.
dumps
(
self
.
to_serializable_dict
())
def
__str__
(
self
):
return
f
"Location({self.__repr__()})"
src/data-hub/community-detection-microservice/app/db/entities/popular_location.py
0 → 100644
View file @
c38ae421
import
json
class
PopularLocation
:
def
__init__
(
self
,
date
,
top_locations
:
list
):
super
()
.
__init__
()
self
.
date
=
date
self
.
top_locations
=
top_locations
def
to_serializable_dict
(
self
,
for_db
=
False
):
return
{
"date"
:
str
(
self
.
date
),
"top-locations"
:
json
.
dumps
(
self
.
top_locations
)
if
for_db
else
self
.
top_locations
}
def
__repr__
(
self
):
return
json
.
dumps
(
self
.
to_serializable_dict
())
def
__str__
(
self
):
return
f
"PopularLocation({self.__repr__()})"
src/data-hub/community-detection-microservice/app/db/entities/user_cluster.py
0 → 100644
View file @
c38ae421
import
json
class
UserCluster
:
def
__init__
(
self
,
date
,
hour
,
clusters
):
super
()
.
__init__
()
self
.
date
=
date
self
.
hour
=
hour
self
.
clusters
=
clusters
self
.
id
=
f
'{self.date}-{self.hour}'
def
to_serializable_dict
(
self
,
for_db
=
False
):
return
{
"id"
:
self
.
id
,
"date"
:
str
(
self
.
date
),
"hour"
:
self
.
hour
,
"clusters"
:
json
.
dumps
(
self
.
clusters
)
if
for_db
else
self
.
clusters
}
def
__repr__
(
self
):
return
json
.
dumps
(
self
.
to_serializable_dict
())
def
__str__
(
self
):
return
f
"UserCluster({self.__repr__()})"
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