Skip to content

Commit

Permalink
return jsonify() from api rather than json.dumps()
Browse files Browse the repository at this point in the history
  • Loading branch information
adhil0 committed Oct 5, 2023
1 parent 00f3bd6 commit 64b499e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions dashboard/src/t5gweb/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""API endpoints for t5gweb"""
import json

from flask import Blueprint, request
from flask import Blueprint, request, jsonify
from flask_login import login_required
from t5gweb.cache import (
get_bz_details,
Expand Down Expand Up @@ -50,86 +50,86 @@ def refresh(data_type):
cfg = set_cfg()
if data_type == "cards":
get_cards(cfg)
return {"caching cards": "ok"}
return jsonify({"caching cards": "ok"})
elif data_type == "cases":
get_cases(cfg)
return {"caching cases": "ok"}
return jsonify({"caching cases": "ok"})
elif data_type == "details":
get_case_details(cfg)
return {"caching details": "ok"}
return jsonify({"caching details": "ok"})
elif data_type == "bugs":
get_bz_details(cfg)
elif data_type == "escalations":
get_escalations(cfg)
return {"caching escalations": "ok"}
return jsonify({"caching escalations": "ok"})
elif data_type == "watchlist":
get_watchlist(cfg)
return {"caching watchlist": "ok"}
return jsonify({"caching watchlist": "ok"})
elif data_type == "issues":
get_issue_details(cfg)
return {"caching issues": "ok"}
return jsonify({"caching issues": "ok"})
else:
return {"error": "unknown data type: {}".format(data_type)}
return jsonify({"error": "unknown data type: {}".format(data_type)})


@BP.route("/cards")
@login_required
def show_cards():
"""Retrieves all cards"""
cards = redis_get("cards")
return cards
return jsonify(cards)


@BP.route("/cases")
@login_required
def show_cases():
"""Retrieves all cases"""
cases = redis_get("cases")
return cases
return jsonify(cases)


@BP.route("/bugs")
@login_required
def show_bugs():
"""Retrieves all bugs"""
bugs = redis_get("bugs")
return bugs
return jsonify(bugs)


@BP.route("/escalations")
@login_required
def show_escalations():
"""Retrieves all escalations"""
escalations = redis_get("escalations")
return json.dumps(escalations)
return jsonify(escalations)


@BP.route("/watchlist")
@login_required
def show_watched():
"""Retrieves all cases on the watchlist"""
watchlist = redis_get("watchlist")
return json.dumps(watchlist)
return jsonify(watchlist)


@BP.route("/details")
@login_required
def show_details():
"""Retrieves CritSit and Group Name for each case"""
details = redis_get("details")
return json.dumps(details)
return jsonify(details)


@BP.route("/issues")
@login_required
def show_issues():
"""Retrieves all JIRA issues associated with open cases"""
issues = redis_get("issues")
return json.dumps(issues)
return jsonify(issues)


@BP.route("/stats")
@login_required
def show_stats():
stats = generate_stats()
return stats
return jsonify(stats)

0 comments on commit 64b499e

Please sign in to comment.