acikyazilimagi / musahit-harita-backend

Müşahit Haritası Backend Api Kodları
Apache License 2.0
22 stars 2 forks source link

Update Details Endpoint #19

Closed bltMustafa closed 1 year ago

bltMustafa commented 1 year ago

/api/feed/<neighbourhoodId>

determine the timepast field.. check formulation for finalRank output..

{

  "neighbourhoodId": "<-id->",

  "lastUpdateTime": "<-timepast?->",

  "intensity": "<-finalRank->",

  "details": [

    "<-building-name-0-> - <-ballot_boxes.box_no in that building_id-0->",
    "<-building-name-1-> - <-ballot_boxes.box_no in that building_id-1->"
  ],

}
9ssi7 commented 1 year ago

I'm working on it, you can assign me

9ssi7 commented 1 year ago

What do you think about this sql query?

SELECT vc.id AS volunteer_count_id,
       b.id AS building_id, b.name AS building_name,
       bb.box_no
FROM volunteer_counts vc
JOIN (
  SELECT *
  FROM buildings
  WHERE id IN (
    SELECT building_id
    FROM volunteer_counts
    WHERE neighbourhood_id = <params_id>
    LIMIT 1
  )
) b ON vc.building_id = b.id
JOIN ballot_boxes bb ON b.id = bb.building_id;
Example Output: volunteer_count_id building_id building_name box_no
2 3 deneme 123123
2 3 deneme 12312312
gurkanguray commented 1 year ago

/api/feed/<neighbourhoodId>

determine the timepast field.. check formulation for finalRank output..

{

  "neighbourhoodId": "<-id->",

  "lastUpdateTime": "<-timepast?->",

  "intensity": "<-finalRank->",

  "details": [

    "<-building-name-0-> - <-ballot_boxes.box_no in that building_id-0->",
    "<-building-name-1-> - <-ballot_boxes.box_no in that building_id-1->"
  ],

}

Shouldn't the details be better for frontend if something like the below:

"details" : [
  {"building_name": "ATATURK ILKOKULU", "ballot_box_nos": [1,2,3,4,5]}
]

@kingofsevens @bltMustafa @ssibrahimbas

kingofsevens commented 1 year ago

It is better of course.. @bltMustafa can you comment the changes on the FE issue. Thank you

9ssi7 commented 1 year ago

I also find it more logical to send it as an object. It can be shaped as desired in the frontend. However, I can still extract it in that format however you want. It is currently returning as a string as it is written in the issue.