Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mock-cheops
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
chephren
mock-cheops
Commits
2d965b32
Commit
2d965b32
authored
1 year ago
by
REIG Julien
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix' into 'master'
fix peut etre je sais pas trop See merge request
!9
parents
ce19f947
075ddec3
Branches
Branches containing commit
No related tags found
1 merge request
!9
fix peut etre je sais pas trop
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/resource_controller.py
+3
-2
3 additions, 2 deletions
controllers/resource_controller.py
controllers/resources_controller.py
+3
-2
3 additions, 2 deletions
controllers/resources_controller.py
utils/database_utils.py
+1
-1
1 addition, 1 deletion
utils/database_utils.py
with
7 additions
and
5 deletions
controllers/resource_controller.py
+
3
−
2
View file @
2d965b32
...
...
@@ -5,7 +5,8 @@ from flask_restful import Api, Resource
from
consts.status
import
Status
,
response_offline
from
models.command
import
Command
from
utils.database_utils
import
get_resource
,
get_state
,
insert_command
,
update_state
from
utils.database_utils
import
(
get_resource
,
get_state
,
insert_command
,
update_state
)
from
utils.http_utils
import
normalize_url
,
send_command_to_other_nodes
resource_controller
=
Blueprint
(
'
resource_controller
'
,
__name__
)
...
...
@@ -19,7 +20,7 @@ class ResourceResource(Resource):
resource
=
get_resource
(
id
)
if
resource
:
return
jsonify
(
resource
)
return
jsonify
(
resource
.
to_simple_dict
()
)
else
:
return
{
"
message
"
:
"
Resource not found
"
},
404
...
...
This diff is collapsed.
Click to expand it.
controllers/resources_controller.py
+
3
−
2
View file @
2d965b32
...
...
@@ -5,8 +5,9 @@ from flask_restful import Api, Resource
from
consts.status
import
Status
,
response_offline
from
models.command
import
Command
from
utils.database_utils
import
get_resources
,
get_state
,
insert_command
,
insert_resource
,
update_state
from
models.resource
import
Resource
as
ResourceModel
from
utils.database_utils
import
(
get_resources
,
get_state
,
insert_command
,
insert_resource
,
update_state
)
from
utils.http_utils
import
normalize_url
,
send_resource_to_other_nodes
resources_controller
=
Blueprint
(
'
resources_controller
'
,
__name__
)
...
...
@@ -21,7 +22,7 @@ class ResourcesResource(Resource):
resources
=
get_resources
(
page
=
request
.
headers
.
get
(
'
page
'
,
1
,
type
=
int
),
page_size
=
request
.
headers
.
get
(
'
pageSize
'
,
20
,
type
=
int
))
return
jsonify
([
resource
.
to_simple_dict
()
for
resource
in
resources
])
def
put
(
self
):
...
...
This diff is collapsed.
Click to expand it.
utils/database_utils.py
+
1
−
1
View file @
2d965b32
...
...
@@ -67,7 +67,7 @@ def get_resources(with_commands: bool = False, page: int = 1, page_size=20) -> O
if
with_commands
:
return
[
Resource
.
from_tuple
(
resource
,
commands
=
get_commands
(
resource
[
0
]))
for
resource
in
resources
]
return
[
Resource
.
from_tuple
(
resource
,
command_count
=
get_commands_count
(
resource
[
0
]))
for
resource
in
resources
]
return
[
Resource
.
from_tuple
(
resource
,
command
s
_count
=
get_commands_count
(
resource
[
0
]))
for
resource
in
resources
]
except
Exception
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
return
None
...
...
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