Skip to content

Commit

Permalink
fix: [website] Fixed an issue in the Marshalling for the Sightings in…
Browse files Browse the repository at this point in the history
… the API.
  • Loading branch information
cedricbonhomme committed Nov 13, 2024
1 parent 9994dbb commit 5ccdbe2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion website/web/api/v1/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get(self) -> Tuple[ResultType, int]:
results = query.offset(offset * limit)
count = total

result["data"] = results
result["data"] = results.all()
result["metadata"]["count"] = count

return result, 200
Expand Down
2 changes: 1 addition & 1 deletion website/web/api/v1/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get(self) -> Tuple[ResultType, int]:
results = query.offset(offset * limit)
count = total

result["data"] = results
result["data"] = results.all()
result["metadata"]["count"] = count

return result, 200
Expand Down
13 changes: 7 additions & 6 deletions website/web/api/v1/sighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,17 @@ def get(self) -> Tuple[ResultType, int]:
query = query.filter(Sighting.vulnerability.ilike(vuln_id))
if type is not None:
query = query.filter(Sighting.type == type)
query = query.filter(
func.date(Sighting.creation_timestamp) >= date_from,
)

if date_from is not None and date_to is not None:
query = query.filter(
func.date(Sighting.creation_timestamp) >= date_from,
func.date(Sighting.creation_timestamp) <= date_to,
)
query = query.filter(
func.date(Sighting.creation_timestamp) <= date_to,
)
query = query.order_by(Sighting.creation_timestamp.desc())
total = query.count()
query = query.limit(limit)
results = query.offset(offset * limit)
results = query.offset(offset * limit).all()
count = total

result["data"] = results
Expand Down
2 changes: 2 additions & 0 deletions website/web/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@


def is_url(value: str) -> bool:
if not value:
return False
url_pattern = re.compile(
r"^(https?:\/\/)?" # optional scheme
r"(([a-zA-Z\d-]+\.)+[a-zA-Z]{2,}|localhost|" # domain or localhost
Expand Down
1 change: 1 addition & 0 deletions website/web/static/js/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function drawBarChartHomePage(sightings, chartDivId, title, backgroundColor) {
const vulnerabilityCounts = new Map();

// Count occurrences with a regular `for` loop

for (let i = 0; i < sightings.length; i++) {
const vuln = sightings[i].vulnerability.toLowerCase();
vulnerabilityCounts.set(vuln, (vulnerabilityCounts.get(vuln) || 0) + 1);
Expand Down
2 changes: 1 addition & 1 deletion website/web/views/sighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def list_sightings() -> str:
Sighting.uuid == uuid_obj,
Sighting.type == sighting_query,
Sighting.source.ilike("%" + sighting_query + "%"),
Sighting.vulnerability.ilike("%" + sighting_query + "%"),
Sighting.vulnerability.ilike(sighting_query),
Sighting.author.has(login=sighting_query),
)
)
Expand Down

0 comments on commit 5ccdbe2

Please sign in to comment.