From e4a13921124929e1fa07cf90aad49fe3ea0c42f3 Mon Sep 17 00:00:00 2001 From: elraphty Date: Thu, 2 Nov 2023 20:20:05 +0100 Subject: [PATCH 1/4] added decode invoice test From 446140994d1ab70fe9b0fb3ec666734b90bc402e Mon Sep 17 00:00:00 2001 From: elraphty Date: Thu, 9 Nov 2023 14:35:33 +0100 Subject: [PATCH 2/4] removed invoice testing From 31efbb29aeaddbd56f2e9bea0037b33f37abe5cd Mon Sep 17 00:00:00 2001 From: elraphty Date: Thu, 9 Nov 2023 22:33:42 +0100 Subject: [PATCH 3/4] changed ticketemodal to db call --- db/db.go | 10 +++++++++- handlers/bounty.go | 16 ++++++++++++++++ routes/bounty.go | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index 202a58bb0..8832a25d3 100644 --- a/db/db.go +++ b/db/db.go @@ -478,7 +478,7 @@ func (db database) GetOrganizationBounties(r *http.Request, org_uuid string) []B func (db database) GetAssignedBounties(pubkey string) ([]BountyData, error) { ms := []BountyData{} - err := db.db.Raw(`SELECT body.*, body.id as bounty_id, body.description as bounty_description, body.created as bounty_created, body.updated as bounty_updated, body.org_uuid, person.*, person.owner_alias as assignee_alias, person.id as assignee_id, person.description as assignee_description, person.created as assignee_created, person.updated as assignee_updated, person.owner_route_hint as assignee_route_hint, owner.id as bounty_owner_id, owner.uuid as owner_uuid, owner.owner_pub_key as owner_key, owner.owner_alias as owner_alias, owner.description as owner_description, owner.price_to_meet as owner_price_to_meet, owner.unique_name as owner_unique_name, owner.tags as owner_tags, owner.img as owner_img, owner.created as owner_created, owner.updated as owner_updated, owner.last_login as owner_last_login, owner.owner_route_hint as owner_route_hint, owner.owner_contact_key as owner_contact_key, org.name as organization_name, org.uuid as organization_uuid, org.img as organization_img FROM public.bounty AS body LEFT OUTER JOIN public.people AS person ON body.assignee = person.owner_pub_key LEFT OUTER JOIN public.people as owner ON body.owner_id = owner.owner_pub_key LEFT OUTER JOIN public.organizations as org ON body.org_uuid = org.uuid WHERE body.assignee = '` + pubkey + `' ORDER BY body.id DESC`).Find(&ms).Error + err := db.db.Raw(`SELECT body.*, body.id as bounty_id, body.description as bounty_description, body.created as bounty_created, body.updated as bounty_updated, body.org_uuid, person.*, person.owner_alias as assignee_alias, person.id as assignee_id, person.description as assignee_description, person.created as assignee_created, person.updated as assignee_updated, person.owner_route_hint as assignee_route_hint, owner.id as bounty_owner_id, owner.uuid as owner_uuid, owner.owner_pub_key as owner_key, owner.owner_alias as owner_alias, owner.description as owner_description, owner.price_to_meet as owner_price_to_meet, owner.unique_name as owner_unique_name, owner.tags as owner_tags, owner.img as owner_img, owner.created as owner_created, owner.updated as owner_updated, owner.last_login as owner_last_login, owner.owner_route_hint as owner_route_hint, owner.owner_contact_key as owner_contact_key, org.name as organization_name, org.uuid as organization_uuid, org.img as organization_img FROM public.bounty AS body LEFT OUTER JOIN public.people AS person ON body.assignee = person.owner_pub_key LEFT OUTER JOIN public.people as owner ON body.owner_id = owner.owner_pub_key LEFT OUTER JOIN public.organizations as org ON body.org_uuid = org.uuid WHERE body.assignee = '` + pubkey + `' AND body.show != false ORDER BY body.id DESC`).Find(&ms).Error return ms, err } @@ -499,6 +499,14 @@ func (db database) GetBountyById(id string) ([]BountyData, error) { return ms, err } +func (db database) GetBountyDataByCreated(created string) ([]BountyData, error) { + ms := []BountyData{} + + err := db.db.Raw(`SELECT body.*, body.id as bounty_id, body.description as bounty_description, body.created as bounty_created, body.updated as bounty_updated, body.org_uuid, person.*, person.owner_alias as assignee_alias, person.id as assignee_id, person.description as assignee_description, person.created as assignee_created, person.updated as assignee_updated, person.owner_route_hint as assignee_route_hint, owner.id as bounty_owner_id, owner.uuid as owner_uuid, owner.owner_pub_key as owner_key, owner.owner_alias as owner_alias, owner.description as owner_description, owner.price_to_meet as owner_price_to_meet, owner.unique_name as owner_unique_name, owner.tags as owner_tags, owner.img as owner_img, owner.created as owner_created, owner.updated as owner_updated, owner.last_login as owner_last_login, owner.owner_route_hint as owner_route_hint, owner.owner_contact_key as owner_contact_key, org.name as organization_name, org.uuid as organization_uuid, org.img as organization_img FROM public.bounty AS body LEFT OUTER JOIN public.people AS person ON body.assignee = person.owner_pub_key LEFT OUTER JOIN public.people as owner ON body.owner_id = owner.owner_pub_key LEFT OUTER JOIN public.organizations as org ON body.org_uuid = org.uuid WHERE body.created = '` + created + `' ORDER BY body.id DESC`).Find(&ms).Error + + return ms, err +} + func (db database) AddBounty(b Bounty) (Bounty, error) { db.db.Create(&b) return b, nil diff --git a/handlers/bounty.go b/handlers/bounty.go index c10b7f61f..d9a034c6c 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -41,6 +41,22 @@ func GetBountyById(w http.ResponseWriter, r *http.Request) { } } +func GetBountyByCreated(w http.ResponseWriter, r *http.Request) { + created := chi.URLParam(r, "created") + if created == "" { + w.WriteHeader(http.StatusNotFound) + } + bounties, err := db.DB.GetBountyDataByCreated(created) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + fmt.Println("Error", err) + } else { + var bountyResponse []db.BountyResponse = generateBountyResponse(bounties) + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(bountyResponse) + } +} + func GetBountyCount(w http.ResponseWriter, r *http.Request) { personKey := chi.URLParam(r, "personKey") tabType := chi.URLParam(r, "tabType") diff --git a/routes/bounty.go b/routes/bounty.go index 101fde1fb..3bad69455 100644 --- a/routes/bounty.go +++ b/routes/bounty.go @@ -16,6 +16,7 @@ func BountyRoutes() chi.Router { r.Get("/all", handlers.GetAllBounties) r.Get("/id/{bountyId}", handlers.GetBountyById) + r.Get("/created/{created}", handlers.GetBountyByCreated) r.Get("/count/{personKey}/{tabType}", handlers.GetBountyCount) r.Get("/invoice/{paymentRequest}", handlers.GetInvoiceData) From 3f08f0193fe6d9cdbc6056b43967eeef593d6c48 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 10 Nov 2023 00:21:58 +0100 Subject: [PATCH 4/4] fixed bounty modal, to making calls on the backend