Compare commits

...

2 Commits

Author SHA1 Message Date
Anna 24dfc9ded5
feat: add response to output 2023-11-17 13:30:56 -05:00
Anna af3148df06
chore: bump version to 1.0.6 2023-11-17 13:30:45 -05:00
3 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@ -137,7 +137,7 @@ async fn get_data(
select
q.*,
current_timestamp <= q.publish_date + interval '1 day' and current_timestamp > q.publish_date as "active!",
exists(select 1 from responses r where r.question_id = q.id and r.user_id = $1) as "voted!"
(select answer from responses r where r.question_id = q.id and r.user_id = $1) as response
from questions q
where q.publish_date <= current_timestamp
order by q.publish_date desc
@ -170,10 +170,11 @@ async fn get_data(
answers: question.answers,
};
if question.voted || !question.active {
if question.response.is_some() || !question.active {
parsed.push(FullQuestion {
basic,
responses,
response: question.response.map(|r| r as u16),
}.into());
} else {
parsed.push(basic.into());

View File

@ -16,6 +16,7 @@ pub struct FullQuestion {
#[serde(flatten)]
pub basic: BasicQuestion,
pub responses: Vec<u64>,
pub response: Option<u16>,
}
#[derive(Serialize)]