Sped up loading of individual speech list
This commit is contained in:
parent
e7eb638e29
commit
2a1127d68c
3 changed files with 42 additions and 3 deletions
|
@ -331,6 +331,46 @@ public class MongoPprUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementiert von Valentin
|
||||
* Holt alle Reden eines Parlamentariers
|
||||
* @param speakerId
|
||||
* @return
|
||||
*/
|
||||
public static List<SpeechOverview> getSpeechesOverviewForSpeaker(Integer speakerId) {
|
||||
|
||||
List<SpeechOverview> result = new ArrayList<>();
|
||||
|
||||
MongoCollection<Document> collection = getSpeechCollection();
|
||||
|
||||
Document projection = new Document("speechKey", 1)
|
||||
.append("speakerId", 1)
|
||||
.append("dateTimeString", 1)
|
||||
.append("speakerName", 1)
|
||||
.append("fraction", 1)
|
||||
.append("agendaTitel", 1);
|
||||
|
||||
Bson filter = Filters.eq("speakerId", speakerId);
|
||||
|
||||
List<Document> docs = collection.find(filter)
|
||||
.projection(projection)
|
||||
.sort(Sorts.descending("dateTime"))
|
||||
.into(new ArrayList<>());
|
||||
|
||||
for (Document doc : docs) {
|
||||
result.add(new SpeechOverview(
|
||||
doc.getString("speechKey"),
|
||||
doc.getInteger("speakerId"),
|
||||
doc.getString("dateTimeString"),
|
||||
doc.getString("speakerName"),
|
||||
doc.getString("fraction"),
|
||||
doc.getString("agendaTitel")
|
||||
));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementiert von Valentin
|
||||
|
|
|
@ -45,8 +45,7 @@ public class SpeechController {
|
|||
String parlamentarierId = ctx.pathParam("id");
|
||||
|
||||
ParlamentarierDetails p = MongoPprUtils.getParlamentarierDetailsByID(parlamentarierId);
|
||||
List<SpeechMetaData> speechMetaDataList = MongoPprUtils.getSpeechesMetadataForSpeaker(parlamentarierId);
|
||||
|
||||
List<SpeechOverview> speechMetaDataList = MongoPprUtils.getSpeechesOverviewForSpeaker(Integer.parseInt(parlamentarierId));
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
attributes.put("p", p);
|
||||
attributes.put("speechesMetaDataList", speechMetaDataList);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<#list speechesMetaDataList as redeMd>
|
||||
<tr>
|
||||
<td>${redeMd.dateTimeString}</td>
|
||||
<td><a href="/reden/${p.id}/${redeMd.speechKey}">${redeMd.agendaTitle}</a></td>
|
||||
<td><a href="/reden/${p.id}/${redeMd.speechKey}">${redeMd.agendaTitel}</a></td>
|
||||
</tr>
|
||||
</#list>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue