Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
StorageLeaf
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ProjectLeaf
StorageLeaf
Commits
e02f2cba
Commit
e02f2cba
authored
3 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
v2.2.0; added new rout to retrieve database info (e.g. size on disk and number of measurements)
parent
19065ecd
Branches
Branches containing commit
Tags
v2.2.0
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/StorageLeaf.py
+18
-2
18 additions, 2 deletions
src/StorageLeaf.py
src/logic/database/Crud.py
+4
-0
4 additions, 0 deletions
src/logic/database/Crud.py
src/logic/database/Schemas.py
+13
-0
13 additions, 0 deletions
src/logic/database/Schemas.py
src/version.json
+3
-3
3 additions, 3 deletions
src/version.json
with
38 additions
and
5 deletions
src/StorageLeaf.py
+
18
−
2
View file @
e02f2cba
...
...
@@ -3,15 +3,17 @@ import os
import
uvicorn
from
TheCodeLabs_BaseUtils.DefaultLogger
import
DefaultLogger
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
,
Depends
from
fastapi.openapi.docs
import
get_swagger_ui_html
,
get_redoc_html
from
fastapi.middleware.cors
import
CORSMiddleware
from
sqlalchemy.orm
import
Session
from
starlette.responses
import
RedirectResponse
,
FileResponse
from
Settings
import
SETTINGS
from
logic
import
Constants
from
logic.Dependencies
import
get_database
from
logic.DiscoveryService
import
DiscoveryService
from
logic.database
import
Models
,
Schemas
from
logic.database
import
Models
,
Schemas
,
Crud
from
logic.database.Database
import
engine
from
logic.routers
import
DeviceRouter
from
logic.routers
import
SensorRouter
,
MeasurementRouter
...
...
@@ -72,6 +74,20 @@ def overridden_redoc():
redoc_favicon_url
=
app
.
url_path_for
(
'
favicon
'
))
@app.get
(
'
/databaseInfo
'
,
summary
=
'
Gets information about the database version
'
,
tags
=
[
'
general
'
],
response_model
=
Schemas
.
DatabaseInfo
)
async
def
databaseInfo
(
db
:
Session
=
Depends
(
get_database
)):
numberOfMeasurements
=
Crud
.
get_total_number_of_measurements
(
db
)
sizeInBytes
=
os
.
path
.
getsize
(
databaseSettings
[
'
databasePath
'
])
sizeInMegaBytes
=
sizeInBytes
//
1024
//
1024
return
Schemas
.
DatabaseInfo
(
number_of_measurements
=
numberOfMeasurements
,
size_on_disk_in_mb
=
sizeInMegaBytes
)
app
.
include_router
(
DeviceRouter
.
router
)
app
.
include_router
(
SensorRouter
.
router
)
app
.
include_router
(
MeasurementRouter
.
router
)
...
...
This diff is collapsed.
Click to expand it.
src/logic/database/Crud.py
+
4
−
0
View file @
e02f2cba
...
...
@@ -168,5 +168,9 @@ def delete_measurement(db: Session, measurement: Schemas.Measurement):
db
.
commit
()
def
get_total_number_of_measurements
(
db
:
Session
)
->
List
[
int
]:
return
db
.
query
(
Models
.
Measurement
).
count
()
def
__get_current_datetime
():
return
datetime
.
strftime
(
datetime
.
now
(),
DATE_FORMAT
)
This diff is collapsed.
Click to expand it.
src/logic/database/Schemas.py
+
13
−
0
View file @
e02f2cba
...
...
@@ -25,6 +25,19 @@ class Version(BaseModel):
}
class
DatabaseInfo
(
BaseModel
):
number_of_measurements
:
int
size_on_disk_in_mb
:
int
class
Config
:
schema_extra
=
{
'
example
'
:
{
'
number_of_measurements
'
:
1000
,
'
size_on_disk_in_mb
'
:
14
}
}
class
MinMax
(
BaseModel
):
min
:
float
=
None
max
:
float
=
None
...
...
This diff is collapsed.
Click to expand it.
src/version.json
+
3
−
3
View file @
e02f2cba
{
"version"
:
{
"name"
:
"v2.
1
.0"
,
"code"
:
1
5
,
"date"
:
"1
7
.0
5
.21"
"name"
:
"v2.
2
.0"
,
"code"
:
1
6
,
"date"
:
"1
8
.0
8
.21"
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment