Skip to content

Commit

Permalink
Merge pull request #50 from BernhardAuer/39-speech-overview-page-enha…
Browse files Browse the repository at this point in the history
…ncements

39 speech overview page enhancements
  • Loading branch information
BernhardAuer authored Dec 9, 2023
2 parents 12a70d6 + 9f61b03 commit e3164b8
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Backend/Controllers/SpeechesMetaDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ public async Task<List<SpeechesDto>> GetSpeeches([FromQuery] string legislature,
TypeOfSpeech = _austrianParliamentAbbreviationMappings.GetLongNameSpeechType(x.typeOfSpeech),

Check warning on line 37 in Backend/Controllers/SpeechesMetaDataController.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'abbreviation' in 'string AustrianParliamentAbbreviationMappings.GetLongNameSpeechType(string abbreviation)'.
LengthOfSpeechInSec = x.lengthOfSpeechInSec,
SpeechSneakPeak = GetTextWithoutSalutation(x?.speech?.FirstOrDefault(x => x.type == SpeechObjectTypeEnum.Speech)?.data),
SpeechNrInDebate = x.speechNrInDebate ?? 0
SpeechNrInDebate = x.speechNrInDebate ?? 0,

Check warning on line 40 in Backend/Controllers/SpeechesMetaDataController.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
ActivitiesCount = x?. speech == null ? new Dictionary<string, int>(): x.speech
.Where(y => y.parsedInfoItems != null)
.SelectMany(y => y.parsedInfoItems)
.Where(y => y.activityList != null)
.SelectMany(y => y.activityList)
.GroupBy(y => y)
.Select(grp => new
{
activityName = grp.Key,
Count = grp.Count()
}).ToDictionary(y => y.activityName, y => y.Count)
})
.ToList();
return result;
Expand Down
2 changes: 2 additions & 0 deletions Backend/DTOs/SpeechesDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public class SpeechesDto
public string? SpeechSneakPeak { get; set; }

public int SpeechNrInDebate { get; set; }

public Dictionary<string, int> ActivitiesCount { get; set; }

}
2 changes: 2 additions & 0 deletions Backend/Models/Speech.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class Speech
public string data { get; set; }
public string? speaker { get; set; }
public int orderId { get; set; }

public SpeechParsedInfoItem[] parsedInfoItems { get; set; }
}
12 changes: 12 additions & 0 deletions Backend/Models/SpeechParsedInfoItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using WebApi.Enums;

namespace WebApi.Models;

[BsonIgnoreExtraElements]
public class SpeechParsedInfoItem
{
public string[] activityList { get; set; }

Check warning on line 10 in Backend/Models/SpeechParsedInfoItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'activityList' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public SpeechParsedInfoItemEntity[] entityList { get; set; }
}
12 changes: 12 additions & 0 deletions Backend/Models/SpeechParsedInfoItemEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using WebApi.Enums;

namespace WebApi.Models;

[BsonIgnoreExtraElements]
public class SpeechParsedInfoItemEntity
{
public string type { get; set; }

Check warning on line 10 in Backend/Models/SpeechParsedInfoItemEntity.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'type' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string name { get; set; }

Check warning on line 11 in Backend/Models/SpeechParsedInfoItemEntity.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
8 changes: 8 additions & 0 deletions frontend/src/components/LicenseHint.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div role="alert" class="alert shadow-lg ">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div>
<h3 class="font-bold">Lizenziert unter <a class="link" href="https://creativecommons.org/licenses/by/4.0/deed.de">CC BY 4.0</a></h3>
<div class="text-xs">
<a class="link" href="https://www.parlament.gv.at/recherchieren/open-data/daten-und-lizenz/index.html#verwendung_des_datenangebots">Inhalte</a> zur Verfügung gestellt vom © Parlament Österreich</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Name | Type | Description | Notes
**politicalPartie** | **String** | | [optional]
**speechSneakPeak** | **String** | | [optional]
**speechNrInDebate** | **Number** | | [optional]
**activitiesCount** | **{String: Number}** | | [optional]


Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class SpeechesDto {
if (data.hasOwnProperty('speechNrInDebate')) {
obj['speechNrInDebate'] = ApiClient.convertToType(data['speechNrInDebate'], 'Number');
}
if (data.hasOwnProperty('activitiesCount')) {
obj['activitiesCount'] = ApiClient.convertToType(data['activitiesCount'], {'String': 'Number'});
}
}
return obj;
}
Expand Down Expand Up @@ -154,6 +157,11 @@ SpeechesDto.prototype['speechSneakPeak'] = undefined;
*/
SpeechesDto.prototype['speechNrInDebate'] = undefined;

/**
* @member {Object.<String, Number>} activitiesCount
*/
SpeechesDto.prototype['activitiesCount'] = undefined;




Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<svelte:head>
<title>Wortmeldungen | parli-info.org</title>
<title>Wortmeldungen {data.meetingNr}. NR-Sitzung ({data.legislature} GP) | parli-info.org</title>
</svelte:head>

<script>
import LicenseHint from '../../../../components/LicenseHint.svelte';
import TopicAccordion from './TopicAccordion.svelte';
/** @type {import('./$types').PageData} */
export let data;
</script>

<div class="md:2xl:mx-96">
<h1 class="text-4xl font-normal leading-normal mt-0 mb-2 text-blue-800 break-words">
Wortmeldungen der {data.meetingNr}. NR-Sitzung ({data.legislature} GP)
</h1>
</div>

<LicenseHint/>

<div class="py-4 space-y-2">
{#each data.topics as topic}
<TopicAccordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@
<div class="badge badge-outline">
{convertLengthToReadableString(speech.lengthOfSpeechInSec)} min
</div>
{#if "applause" in speech?.activitiesCount}
<div class="badge badge-outline">
<div class="tooltip" data-tip="Beifall">
👏🏻 {speech?.activitiesCount["applause"]}
</div>
</div>
{/if}
{#if "cheerfulness" in speech?.activitiesCount}
<div class="badge badge-outline">
<div class="tooltip" data-tip="Heiterkeit">
😅 {speech?.activitiesCount["cheerfulness"]}
</div>
</div>
{/if}
{#if "shouting" in speech?.activitiesCount}
<div class="badge badge-outline">
<div class="tooltip" data-tip="Zwischenruf">
🗣️ {speech?.activitiesCount["shouting"]}
</div>
</div>
{/if}
</div>
</div>
</div>

0 comments on commit e3164b8

Please sign in to comment.