From ed65a40afcff77cf212ed53b6f5caef39cc2fd70 Mon Sep 17 00:00:00 2001 From: Dariusz Rybi Date: Fri, 29 Jan 2021 15:11:20 +0100 Subject: [PATCH] Still show seen versions in GSB and CLI --- core/version/src/db/dao.rs | 14 ++++++++------ core/version/src/service/cli.rs | 6 ++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/version/src/db/dao.rs b/core/version/src/db/dao.rs index 37d5d9abb6..5a8686b238 100644 --- a/core/version/src/db/dao.rs +++ b/core/version/src/db/dao.rs @@ -41,7 +41,7 @@ impl<'c> ReleaseDAO<'c> { } pub async fn pending_release(&self) -> anyhow::Result> { - readonly_transaction(self.pool, move |conn| get_pending_release(conn)).await + readonly_transaction(self.pool, move |conn| get_pending_release(conn, false)).await } pub async fn version(&self) -> anyhow::Result { @@ -49,7 +49,7 @@ impl<'c> ReleaseDAO<'c> { readonly_transaction(self.pool, move |conn| { Ok(VersionInfo { current: get_current_release(conn)?.ok_or(anyhow!("Can't get current release."))?, - pending: get_pending_release(conn)?, + pending: get_pending_release(conn, true)?, }) }) .await @@ -58,7 +58,7 @@ impl<'c> ReleaseDAO<'c> { pub async fn skip_pending_release(&self) -> anyhow::Result> { log::debug!("Skipping latest pending Yagna release"); do_with_transaction(self.pool, move |conn| { - let mut pending_rel = match get_pending_release(conn)? { + let mut pending_rel = match get_pending_release(conn, false)? { Some(rel) => rel, None => return Ok(None), }; @@ -88,12 +88,14 @@ fn get_release(conn: &ConnType, ver: &str) -> anyhow::Result> { .map(|db_rel| db_rel.into())) } -fn get_pending_release(conn: &ConnType) -> anyhow::Result> { - let query = version_release - .filter(release::seen.eq(false)) +fn get_pending_release(conn: &ConnType, include_seen: bool) -> anyhow::Result> { + let mut query = version_release // insertion_ts is to distinguish among fake-entries of `DBRelease::current` .order((release::release_ts.desc(), release::insertion_ts.desc())) .into_boxed(); + if !include_seen { + query = query.filter(release::seen.eq(false)); + } match query.first::(conn).optional()? { Some(db_rel) => { diff --git a/core/version/src/service/cli.rs b/core/version/src/service/cli.rs index 0095b29203..317a48dc01 100644 --- a/core/version/src/service/cli.rs +++ b/core/version/src/service/cli.rs @@ -8,7 +8,7 @@ const UPDATE_CMD: &'static str = "curl -sSf https://join.golem.network/as-provid #[derive(thiserror::Error, Debug, Clone)] pub(crate) enum ReleaseMessage<'a> { - #[error("New Yagna {0} is available!\nUpdate via\n\t`{UPDATE_CMD}`")] + #[error("New Yagna {0} is available! Update via `{UPDATE_CMD}`")] Available(&'a version::Release), #[error("Your Yagna is up to date: {0}")] UpToDate(&'a version::Release), @@ -81,9 +81,7 @@ mod test { assert_eq!( ReleaseMessage::Available(&r).to_string(), format!( - "New Yagna Version 0.6.1 'some code name' released 2015-10-13 is available!\n\ - Update via\n\ - \t`curl -sSf https://join.golem.network/as-provider | bash -`" + "New Yagna Version 0.6.1 'some code name' released 2015-10-13 is available! Update via `curl -sSf https://join.golem.network/as-provider | bash -`" ) ); }