Skip to content

Commit 6c1b31d

Browse files
committed
More fixes for revision listing and uniqueness
1 parent 02d86a9 commit 6c1b31d

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ members = [
44
"parse-rfd",
55
"rfd-api",
66
"rfd-cli",
7-
"rfd-data", "rfd-github",
7+
"rfd-data",
8+
"rfd-github",
89
"rfd-model",
910
"rfd-processor",
1011
"rfd-redirect",

rfd-api/src/context.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ impl ApiContext {
779779
}
780780
}
781781

782-
#[instrument(skip(self, caller))]
782+
#[instrument(skip(self, caller, content))]
783783
pub async fn update_rfd_content(
784784
&self,
785785
caller: &ApiCaller,
@@ -816,13 +816,20 @@ impl ApiContext {
816816
let sha = latest_revision.commit_sha;
817817
let mut github_locations = self
818818
.github
819-
.locations_for_commit(sha)
819+
.locations_for_commit(sha.clone())
820820
.await
821821
.map_err(UpdateRfdContentError::GitHub)
822822
.to_resource_result()?;
823823

824824
match github_locations.len() {
825-
0 => Err(ResourceError::DoesNotExist),
825+
0 => {
826+
tracing::warn!(
827+
sha,
828+
rfd_number,
829+
"Failed to find a GitHub location for most recent revision"
830+
);
831+
Err(ResourceError::DoesNotExist)
832+
}
826833
1 => {
827834
// Unwrap is checked by the location length
828835
let location = github_locations.pop().unwrap();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP INDEX rfd_revision_commit_sha_idx;
2+
CREATE UNIQUE INDEX rfd_revision_sha_idx ON rfd_revision (rfd_id, sha);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Your SQL goes here

rfd-model/src/storage/postgres.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ impl RfdRevisionStore for PostgresStore {
274274
let query = query
275275
.offset(pagination.offset)
276276
.limit(pagination.limit)
277-
.order((rfd_revision::rfd_id.asc(), rfd_revision::created_at.desc()));
277+
.order((
278+
rfd_revision::rfd_id.asc(),
279+
rfd_revision::committed_at.desc(),
280+
));
278281

279282
let results = query
280283
.get_results_async::<RfdRevisionModel>(&*self.pool.get().await?)

rfd-processor/src/rfd.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,14 @@ impl RemoteRfd {
362362
.await?
363363
.into_iter()
364364
.next()
365-
.map(|revision| revision.id)
366-
.unwrap_or_else(|| Uuid::new_v4());
365+
.map(|revision| {
366+
tracing::info!("Found existing RFD revision for this commit. Updating the revision.");
367+
revision.id
368+
})
369+
.unwrap_or_else(|| {
370+
tracing::info!("No existing revisions exist for this commit. Creating a new revision.");
371+
Uuid::new_v4()
372+
});
367373

368374
let revision = RfdRevisionStore::upsert(
369375
storage,

0 commit comments

Comments
 (0)