Skip to content

Commit 0e73689

Browse files
authored
Distinguish between major and minor changes (#344)
* add major_change field to the schema * serve latest_major_change_at from the api * automatically mark eligible revisions as minor * regenerate sdks * bump versions
1 parent 7b3abba commit 0e73689

File tree

20 files changed

+375
-36
lines changed

20 files changed

+375
-36
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rfd-api-spec.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://oxide.computer",
88
"email": "[email protected]"
99
},
10-
"version": "0.12.0"
10+
"version": "0.12.1"
1111
},
1212
"paths": {
1313
"/.well-known/jwks.json": {
@@ -3846,6 +3846,11 @@
38463846
"id": {
38473847
"$ref": "#/components/schemas/TypedUuidForRfdId"
38483848
},
3849+
"latest_major_change_at": {
3850+
"nullable": true,
3851+
"type": "string",
3852+
"format": "date-time"
3853+
},
38493854
"link": {
38503855
"nullable": true,
38513856
"type": "string"
@@ -4530,6 +4535,9 @@
45304535
"nullable": true,
45314536
"type": "string"
45324537
},
4538+
"major_change": {
4539+
"type": "boolean"
4540+
},
45334541
"rfd_id": {
45344542
"$ref": "#/components/schemas/TypedUuidForRfdId"
45354543
},
@@ -4555,6 +4563,7 @@
45554563
"content_format",
45564564
"created_at",
45574565
"id",
4566+
"major_change",
45584567
"rfd_id",
45594568
"sha",
45604569
"title",
@@ -4662,6 +4671,11 @@
46624671
"nullable": true,
46634672
"type": "string"
46644673
},
4674+
"latest_major_change_at": {
4675+
"nullable": true,
4676+
"type": "string",
4677+
"format": "date-time"
4678+
},
46654679
"link": {
46664680
"nullable": true,
46674681
"type": "string"
@@ -4740,6 +4754,11 @@
47404754
"nullable": true,
47414755
"type": "string"
47424756
},
4757+
"latest_major_change_at": {
4758+
"nullable": true,
4759+
"type": "string",
4760+
"format": "date-time"
4761+
},
47434762
"link": {
47444763
"nullable": true,
47454764
"type": "string"
@@ -4813,6 +4832,11 @@
48134832
"nullable": true,
48144833
"type": "string"
48154834
},
4835+
"latest_major_change_at": {
4836+
"nullable": true,
4837+
"type": "string",
4838+
"format": "date-time"
4839+
},
48164840
"link": {
48174841
"nullable": true,
48184842
"type": "string"

rfd-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rfd-api"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition = "2021"
55
repository = "https://github.com/oxidecomputer/rfd-api"
66

rfd-api/src/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub struct RfdWithRaw {
113113
pub sha: Option<FileSha>,
114114
pub commit: Option<CommitSha>,
115115
pub committed_at: Option<DateTime<Utc>>,
116+
pub latest_major_change_at: Option<DateTime<Utc>>,
116117
pub visibility: Visibility,
117118
}
118119

@@ -153,6 +154,7 @@ impl From<Rfd> for RfdWithRaw {
153154
.content
154155
.as_ref()
155156
.map(|content| content.committed_at.clone()),
157+
latest_major_change_at: value.latest_major_change_at.clone(),
156158
visibility: value.visibility,
157159
}
158160
}
@@ -191,6 +193,7 @@ impl From<RfdMeta> for RfdWithoutContent {
191193
.content
192194
.as_ref()
193195
.map(|content| content.committed_at.clone()),
196+
latest_major_change_at: value.latest_major_change_at.clone(),
194197
visibility: value.visibility,
195198
}
196199
}
@@ -234,6 +237,7 @@ impl From<RfdPdfs> for RfdWithPdf {
234237
.content
235238
.as_ref()
236239
.map(|content| content.committed_at.clone()),
240+
latest_major_change_at: value.latest_major_change_at.clone(),
237241
visibility: value.visibility,
238242
}
239243
}

rfd-api/src/endpoints/rfd.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ mod tests {
941941
sha: FileSha(String::new()),
942942
commit: CommitSha(String::new()),
943943
committed_at: Utc::now(),
944+
major_change: false,
944945
created_at: Utc::now(),
945946
updated_at: Utc::now(),
946947
deleted_at: None,
@@ -949,6 +950,7 @@ mod tests {
949950
updated_at: Utc::now(),
950951
deleted_at: None,
951952
visibility: rfd_model::schema_ext::Visibility::Private,
953+
latest_major_change_at: Some(Utc::now()),
952954
},
953955
Rfd {
954956
id: TypedUuid::from_untyped_uuid(public_rfd_id),
@@ -967,6 +969,7 @@ mod tests {
967969
sha: FileSha(String::new()),
968970
commit: CommitSha(String::new()),
969971
committed_at: Utc::now(),
972+
major_change: false,
970973
created_at: Utc::now(),
971974
updated_at: Utc::now(),
972975
deleted_at: None,
@@ -975,6 +978,7 @@ mod tests {
975978
updated_at: Utc::now(),
976979
deleted_at: None,
977980
visibility: rfd_model::schema_ext::Visibility::Public,
981+
latest_major_change_at: Some(Utc::now()),
978982
},
979983
Rfd {
980984
id: TypedUuid::from_untyped_uuid(private_rfd_id_2),
@@ -993,6 +997,7 @@ mod tests {
993997
sha: FileSha(String::new()),
994998
commit: CommitSha(String::new()),
995999
committed_at: Utc::now(),
1000+
major_change: false,
9961001
created_at: Utc::now(),
9971002
updated_at: Utc::now(),
9981003
deleted_at: None,
@@ -1001,6 +1006,7 @@ mod tests {
10011006
updated_at: Utc::now(),
10021007
deleted_at: None,
10031008
visibility: rfd_model::schema_ext::Visibility::Private,
1009+
latest_major_change_at: Some(Utc::now()),
10041010
},
10051011
];
10061012

@@ -1036,6 +1042,7 @@ mod tests {
10361042
sha: FileSha(String::new()),
10371043
commit: CommitSha(String::new()),
10381044
committed_at: Utc::now(),
1045+
major_change: false,
10391046
created_at: Utc::now(),
10401047
updated_at: Utc::now(),
10411048
deleted_at: None,
@@ -1044,6 +1051,7 @@ mod tests {
10441051
updated_at: Utc::now(),
10451052
deleted_at: None,
10461053
visibility: rfd_model::schema_ext::Visibility::Private,
1054+
latest_major_change_at: Some(Utc::now()),
10471055
},
10481056
RfdMeta {
10491057
id: TypedUuid::from_untyped_uuid(public_rfd_id),
@@ -1061,6 +1069,7 @@ mod tests {
10611069
sha: FileSha(String::new()),
10621070
commit: CommitSha(String::new()),
10631071
committed_at: Utc::now(),
1072+
major_change: false,
10641073
created_at: Utc::now(),
10651074
updated_at: Utc::now(),
10661075
deleted_at: None,
@@ -1069,6 +1078,7 @@ mod tests {
10691078
updated_at: Utc::now(),
10701079
deleted_at: None,
10711080
visibility: rfd_model::schema_ext::Visibility::Public,
1081+
latest_major_change_at: Some(Utc::now()),
10721082
},
10731083
RfdMeta {
10741084
id: TypedUuid::from_untyped_uuid(private_rfd_id_2),
@@ -1086,6 +1096,7 @@ mod tests {
10861096
sha: FileSha(String::new()),
10871097
commit: CommitSha(String::new()),
10881098
committed_at: Utc::now(),
1099+
major_change: false,
10891100
created_at: Utc::now(),
10901101
updated_at: Utc::now(),
10911102
deleted_at: None,
@@ -1094,6 +1105,7 @@ mod tests {
10941105
updated_at: Utc::now(),
10951106
deleted_at: None,
10961107
visibility: rfd_model::schema_ext::Visibility::Private,
1108+
latest_major_change_at: Some(Utc::now()),
10971109
},
10981110
];
10991111

@@ -1131,6 +1143,7 @@ mod tests {
11311143
sha: String::new().into(),
11321144
commit: String::new().into(),
11331145
committed_at: Utc::now(),
1146+
major_change: false,
11341147
created_at: Utc::now(),
11351148
updated_at: Utc::now(),
11361149
deleted_at: None,
@@ -1148,6 +1161,7 @@ mod tests {
11481161
sha: String::new().into(),
11491162
commit: String::new().into(),
11501163
committed_at: Utc::now(),
1164+
major_change: false,
11511165
created_at: Utc::now(),
11521166
updated_at: Utc::now(),
11531167
deleted_at: None,
@@ -1165,6 +1179,7 @@ mod tests {
11651179
sha: String::new().into(),
11661180
commit: String::new().into(),
11671181
committed_at: Utc::now(),
1182+
major_change: false,
11681183
created_at: Utc::now(),
11691184
updated_at: Utc::now(),
11701185
deleted_at: None,
@@ -1196,6 +1211,7 @@ mod tests {
11961211
sha: String::new().into(),
11971212
commit: String::new().into(),
11981213
committed_at: Utc::now(),
1214+
major_change: false,
11991215
created_at: Utc::now(),
12001216
updated_at: Utc::now(),
12011217
deleted_at: None,
@@ -1212,6 +1228,7 @@ mod tests {
12121228
sha: String::new().into(),
12131229
commit: String::new().into(),
12141230
committed_at: Utc::now(),
1231+
major_change: false,
12151232
created_at: Utc::now(),
12161233
updated_at: Utc::now(),
12171234
deleted_at: None,
@@ -1228,6 +1245,7 @@ mod tests {
12281245
sha: String::new().into(),
12291246
commit: String::new().into(),
12301247
committed_at: Utc::now(),
1248+
major_change: false,
12311249
created_at: Utc::now(),
12321250
updated_at: Utc::now(),
12331251
deleted_at: None,

rfd-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rfd-cli"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition = "2021"
55

66
[features]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE rfd_revision DROP COLUMN major_change;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Adding the column in three steps to ensure all rows have a default.
2+
ALTER TABLE rfd_revision ADD COLUMN major_change BOOLEAN;
3+
UPDATE rfd_revision SET major_change = TRUE;
4+
ALTER TABLE rfd_revision ALTER COLUMN major_change SET NOT NULL;

rfd-model/src/db.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub struct RfdMetaJoinRow {
7676
pub revision_updated_at: DateTime<Utc>,
7777
pub revision_deleted_at: Option<DateTime<Utc>>,
7878
pub revision_labels: Option<String>,
79+
pub revision_major_change: bool,
80+
pub latest_major_change_at: Option<DateTime<Utc>>,
7981
}
8082

8183
#[derive(QueryableByName)]
@@ -111,6 +113,8 @@ pub struct RfdPdfJoinRow {
111113
pub revision_updated_at: DateTime<Utc>,
112114
pub revision_deleted_at: Option<DateTime<Utc>>,
113115
pub revision_labels: Option<String>,
116+
pub revision_major_change: bool,
117+
pub latest_major_change_at: Option<DateTime<Utc>>,
114118
}
115119

116120
#[partial(RfdRevisionMetaModel)]
@@ -135,9 +139,10 @@ pub struct RfdRevisionModel {
135139
pub updated_at: DateTime<Utc>,
136140
pub deleted_at: Option<DateTime<Utc>>,
137141
pub labels: Option<String>,
142+
pub major_change: bool,
138143
}
139144

140-
impl From<RfdMetaJoinRow> for (RfdModel, RfdRevisionMetaModel) {
145+
impl From<RfdMetaJoinRow> for (RfdModel, RfdLatestMajorChange, RfdRevisionMetaModel) {
141146
fn from(value: RfdMetaJoinRow) -> Self {
142147
(
143148
RfdModel {
@@ -149,6 +154,9 @@ impl From<RfdMetaJoinRow> for (RfdModel, RfdRevisionMetaModel) {
149154
deleted_at: value.deleted_at,
150155
visibility: value.visibility,
151156
},
157+
RfdLatestMajorChange {
158+
committed_at: value.latest_major_change_at,
159+
},
152160
RfdRevisionMetaModel {
153161
id: value.revision_id,
154162
rfd_id: value.revision_rfd_id,
@@ -164,12 +172,13 @@ impl From<RfdMetaJoinRow> for (RfdModel, RfdRevisionMetaModel) {
164172
updated_at: value.revision_updated_at,
165173
deleted_at: value.revision_deleted_at,
166174
labels: value.revision_labels,
175+
major_change: value.revision_major_change,
167176
},
168177
)
169178
}
170179
}
171180

172-
impl From<RfdPdfJoinRow> for (RfdModel, RfdRevisionPdfModel) {
181+
impl From<RfdPdfJoinRow> for (RfdModel, RfdLatestMajorChange, RfdRevisionPdfModel) {
173182
fn from(value: RfdPdfJoinRow) -> Self {
174183
(
175184
RfdModel {
@@ -181,6 +190,9 @@ impl From<RfdPdfJoinRow> for (RfdModel, RfdRevisionPdfModel) {
181190
deleted_at: value.deleted_at,
182191
visibility: value.visibility,
183192
},
193+
RfdLatestMajorChange {
194+
committed_at: value.latest_major_change_at,
195+
},
184196
RfdRevisionPdfModel {
185197
id: value.revision_id,
186198
rfd_id: value.revision_rfd_id,
@@ -207,6 +219,7 @@ impl From<RfdPdfJoinRow> for (RfdModel, RfdRevisionPdfModel) {
207219
updated_at: value.revision_updated_at,
208220
deleted_at: value.revision_deleted_at,
209221
labels: value.revision_labels,
222+
major_change: value.revision_major_change,
210223
},
211224
)
212225
}
@@ -241,3 +254,8 @@ pub struct JobModel {
241254
pub created_at: DateTime<Utc>,
242255
pub started_at: Option<DateTime<Utc>>,
243256
}
257+
258+
#[derive(Debug)]
259+
pub(crate) struct RfdLatestMajorChange {
260+
pub(crate) committed_at: Option<DateTime<Utc>>,
261+
}

0 commit comments

Comments
 (0)