Skip to content

Commit

Permalink
chg: [website] Reduced the size of the data returned by Get All Sight…
Browse files Browse the repository at this point in the history
…ings API endpoint.
  • Loading branch information
cedricbonhomme committed Nov 4, 2024
1 parent 51f4492 commit cbff442
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 1 addition & 3 deletions website/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ def generate_apikey(self) -> str:
return self.apikey

def __str__(self) -> str:
return "Login: {}\nLast seen: {}\nIs active: {}\nIs admin: {}".format(
self.login, self.last_seen, self.is_active, self.is_admin
)
return str(self.uuid)

@validates("login")
def validates_login(self, key: str, value: str) -> str:
Expand Down
4 changes: 2 additions & 2 deletions website/web/api/v1/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from website.validators import validate_json
from website.web.api.v1.common import auth_func
from website.web.api.v1.common import metada_params_model
from website.web.api.v1.common import user_light_params_model
from website.web.api.v1.common import user_params_model
from website.web.api.v1.common import uuid_type
from website.web.api.v1.types import ResultType
from website.models import Bundle
Expand Down Expand Up @@ -84,7 +84,7 @@
metadata = bundle_ns.model("metadata", metada_params_model)

bundle["author"] = fields.Nested(
bundle_ns.model("User", user_light_params_model), readonly=True
bundle_ns.model("User", user_params_model), readonly=True
)

bundle_list_fields = bundle_ns.model(
Expand Down
4 changes: 2 additions & 2 deletions website/web/api/v1/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from website.validators import validate_json
from website.web.api.v1.common import auth_func
from website.web.api.v1.common import metada_params_model
from website.web.api.v1.common import user_light_params_model
from website.web.api.v1.common import user_params_model
from website.web.api.v1.common import uuid_type
from website.web.api.v1.types import ResultType
from website.models import Comment
Expand Down Expand Up @@ -90,7 +90,7 @@
metadata = comment_ns.model("metadata", metada_params_model)

comment["author"] = fields.Nested(
comment_ns.model("User", user_light_params_model), readonly=True
comment_ns.model("User", user_params_model), readonly=True
)

comment_list_fields = comment_ns.model(
Expand Down
6 changes: 5 additions & 1 deletion website/web/api/v1/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ def uuid_type(value: str) -> uuid.UUID:
"limit": fields.Integer(readonly=True, description="Requested limit data."),
}

user_light_params_model = {
user_params_model = {
"login": fields.String(readonly=True, description="Login of the user."),
"name": fields.String(readonly=True, description="Name of the user."),
"uuid": fields.String(readonly=True, description="UUID of the user."),
}

user_light_params_model = {
"uuid": fields.String(readonly=True, description="UUID of the user."),
}
15 changes: 6 additions & 9 deletions website/web/api/v1/sighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@
# Response marshalling
sighting_params_model = {
"uuid": fields.String(description="Sighting UUID.", readonly=True),
"vulnerability_lookup_origin": fields.String(
description="UUID of the Vulnerability Lookup origin instance.",
readonly=True,
default=local_instance_uuid,
),
# "vulnerability_lookup_origin": fields.String(
# description="UUID of the Vulnerability Lookup origin instance.",
# readonly=True,
# default=local_instance_uuid,
# ),
# "author": fields.String(description="Author of the sighting."),
"creation_timestamp": fields.DateTime(
description="Creation time of the sighting.", readonly=True
),
Expand All @@ -101,10 +102,6 @@
sighting = sighting_ns.model("Sighting", sighting_params_model)
metadata = sighting_ns.model("metadata", metada_params_model)

sighting["author"] = fields.Nested(
sighting_ns.model("User", user_light_params_model), readonly=True
)

sighting_list_fields = sighting_ns.model(
"SightingsList",
{
Expand Down

0 comments on commit cbff442

Please sign in to comment.