-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Phase Tickets API: Route
, Handler
, and Utility Function
#1994
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"os" | ||
|
||
"github.com/go-chi/chi" | ||
"github.com/google/uuid" | ||
"github.com/rs/xid" | ||
"github.com/stakwork/sphinx-tribes/auth" | ||
"github.com/stakwork/sphinx-tribes/db" | ||
|
@@ -697,3 +698,45 @@ func (oh *featureHandler) BriefSend(w http.ResponseWriter, r *http.Request) { | |
w.WriteHeader(resp.StatusCode) | ||
w.Write(respBody) | ||
} | ||
|
||
func (oh *featureHandler) GetTickets(w http.ResponseWriter, r *http.Request) { | ||
ctx := r.Context() | ||
pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) | ||
if pubKeyFromAuth == "" { | ||
fmt.Println("no pubkey from auth") | ||
w.WriteHeader(http.StatusUnauthorized) | ||
return | ||
} | ||
|
||
featureUuid := chi.URLParam(r, "feature_uuid") | ||
phaseUuid := chi.URLParam(r, "phase_uuid") | ||
|
||
if _, err := uuid.Parse(featureUuid); err != nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
json.NewEncoder(w).Encode(map[string]string{"error": "Invalid feature UUID format"}) | ||
return | ||
} | ||
|
||
if _, err := uuid.Parse(phaseUuid); err != nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
json.NewEncoder(w).Encode(map[string]string{"error": "Invalid phase UUID format"}) | ||
return | ||
} | ||
|
||
_, err := oh.db.GetFeaturePhaseByUuid(featureUuid, phaseUuid) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You suppose to use this new function |
||
if err != nil { | ||
w.WriteHeader(http.StatusNotFound) | ||
json.NewEncoder(w).Encode(map[string]string{"error": "Phase not found"}) | ||
return | ||
} | ||
|
||
tickets, err := oh.db.GetTicketsByPhase(featureUuid, phaseUuid) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also based on the issue related to this, you are suppose to return only the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm this should have been updated and the approach is corrrect. Initially I had a design to return uuids and then use a different operation to get all details. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a situation where the description in the ticket was correct but I'd not updated the title which still referenced UUIDs (updated) |
||
if err != nil { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
json.NewEncoder(w).Encode(map[string]string{"error": err.Error()}) | ||
return | ||
} | ||
|
||
w.WriteHeader(http.StatusOK) | ||
json.NewEncoder(w).Encode(tickets) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MuhammadUmer44 we are to get tickets by
phaseUuid
alone not byphaseUuid
andfeatureUuid
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no concept currently where we would have phases without a feature so this logic is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MuhammadUmer44 can you resolve this one so we can get it merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@humansinstitute, Sure, I am on it.