@@ -132,6 +132,20 @@ public GroupedPlacesResponse getPlacesByMidpointGrouped(
132132 }
133133 var myVoteSlotSet = new java .util .HashSet <>(myVoteSlotNos );
134134
135+ // 🔢 Prefetch vote counts for this meeting (slotNo -> count)
136+ Map <Integer , Integer > voteCountMap = new java .util .HashMap <>();
137+ try {
138+ var counts = voteRepository .findVoteCountsByMeeting (meeting ); // returns DTO/projection with slotNo & voteCount(Long)
139+ for (var c : counts ) {
140+ int slot = c .getSlotNo ();
141+ int cnt = c .getVoteCount ();
142+ voteCountMap .put (slot , cnt );
143+ }
144+ } catch (Exception e ) {
145+ log .warn ("[PlaceService] Failed to prefetch vote counts: {}" , e .toString ());
146+ }
147+
148+
135149 List <PlaceSectionDto > sections = new ArrayList <>();
136150 if (meeting .getType () == MeetingType .SOCIAL ) {
137151 log .info ("[PlaceService] Processing SOCIAL meeting - page={}" , pageLocal );
@@ -169,6 +183,10 @@ public GroupedPlacesResponse getPlacesByMidpointGrouped(
169183 }
170184 }
171185
186+ for (PlaceResponseDto p : items ) {
187+ p .setVoteCount (voteCountMap .getOrDefault (p .getSlotNo (), 0 ));
188+ }
189+
172190 for (PlaceResponseDto p : items ) {
173191 upsertCandidate (meeting , p .getSlotNo (), sec , "category" , seedJson );
174192 }
@@ -210,6 +228,10 @@ public GroupedPlacesResponse getPlacesByMidpointGrouped(
210228 }
211229 }
212230
231+ for (PlaceResponseDto p : items ) {
232+ p .setVoteCount (voteCountMap .getOrDefault (p .getSlotNo (), 0 ));
233+ }
234+
213235 for (PlaceResponseDto p : items ) {
214236 upsertCandidate (meeting , p .getSlotNo (), PlaceSection .STUDY , "keyword" , projectSeed );
215237 }
0 commit comments