Skip to content

Commit

Permalink
Do not sort unpublished reports by create_date
Browse files Browse the repository at this point in the history
  • Loading branch information
SLASHLogin committed Oct 17, 2023
1 parent 0f1f4df commit 45a1ed1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/database/models/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ impl Report {
Ok((reports, total_pages))
}

/// Returns all unpublished reports from before the given date.
pub fn get_unpublished_reports(date: NaiveDate) -> Result<Vec<Self>, Error> {
/// Returns all unpublished reports
pub fn get_unpublished_reports() -> Result<Vec<Self>, Error> {
Ok(dsl::report
.filter(dsl::published.eq(false))
.filter(dsl::create_date.lt(date))
.load(&mut PG_POOL.get()?)?)
}

Expand Down Expand Up @@ -140,9 +139,8 @@ impl Report {
pub(crate) async fn report_summary(
summary: Option<Summary>,
publish: bool,
date: NaiveDate,
) -> Result<String, Error> {
let mut reports = Report::get_unpublished_reports(date)?;
let mut reports = Report::get_unpublished_reports()?;

// get reports associated with summary
if let Some(summary) = &summary {
Expand Down
4 changes: 1 addition & 3 deletions src/database/models/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ impl Summary {
summary.push_str("\n\n**Raporty z tego tygodnia:**\n");
let save_summary = Summary::find_by_id(meeting.summary_id())?;

summary.push_str(
&Report::report_summary(Some(save_summary), publish, self.create_date).await?,
);
summary.push_str(&Report::report_summary(Some(save_summary), publish).await?);

summary.push_str("\n**Notatka ze spotkania:**\n");
summary.push_str(&note);
Expand Down

0 comments on commit 45a1ed1

Please sign in to comment.