Skip to content

Commit df61f2a

Browse files
committed
Fix SQLite/Postgres conversion binaries
1 parent 3c758be commit df61f2a

File tree

2 files changed

+5
-60
lines changed

2 files changed

+5
-60
lines changed

database/src/bin/postgres-to-sqlite.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ impl Table for Error {
191191
}
192192

193193
fn postgres_select_statement(&self, since_weeks_ago: Option<u32>) -> String {
194-
let s = "select series, aid, error from ".to_string() + self.name();
194+
let s = "select benchmark, aid, error from ".to_string() + self.name();
195195
with_filter_clause_maybe(s, ARTIFACT_JOIN_AND_WHERE, since_weeks_ago)
196196
}
197197

198198
fn sqlite_insert_statement(&self) -> &'static str {
199-
"insert into error (series, aid, error) VALUES (?, ?, ?)"
199+
"insert into error (benchmark, aid, error) VALUES (?, ?, ?)"
200200
}
201201

202202
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
@@ -210,28 +210,6 @@ impl Table for Error {
210210
}
211211
}
212212

213-
struct ErrorSeries;
214-
215-
impl Table for ErrorSeries {
216-
fn name(&self) -> &'static str {
217-
"error_series"
218-
}
219-
220-
fn postgres_select_statement(&self, _since_weeks_ago: Option<u32>) -> String {
221-
"select id, crate from ".to_string() + self.name()
222-
}
223-
224-
fn sqlite_insert_statement(&self) -> &'static str {
225-
"insert into error_series (id, crate) VALUES (?, ?)"
226-
}
227-
228-
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
229-
statement
230-
.execute(params![row.get::<_, i32>(0), row.get::<_, &str>(1)])
231-
.unwrap();
232-
}
233-
}
234-
235213
struct Pstat;
236214

237215
impl Table for Pstat {
@@ -450,7 +428,6 @@ async fn main() -> anyhow::Result<()> {
450428
&Benchmark,
451429
&Collection,
452430
&CollectorProgress,
453-
&ErrorSeries,
454431
&Error,
455432
&PstatSeries,
456433
&Pstat,

database/src/bin/sqlite-to-postgres.rs

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ struct Error;
218218

219219
#[derive(Serialize)]
220220
struct ErrorRow<'a> {
221-
series: i32,
221+
benchmark: &'a str,
222222
aid: i32,
223223
error: Nullable<&'a str>,
224224
}
@@ -229,7 +229,7 @@ impl Table for Error {
229229
}
230230

231231
fn sqlite_attributes() -> &'static str {
232-
"series, aid, error"
232+
"benchmark, aid, error"
233233
}
234234

235235
fn postgres_generated_id_attribute() -> Option<&'static str> {
@@ -239,45 +239,14 @@ impl Table for Error {
239239
fn write_postgres_csv_row<W: Write>(writer: &mut csv::Writer<W>, row: &rusqlite::Row) {
240240
writer
241241
.serialize(ErrorRow {
242-
series: row.get(0).unwrap(),
242+
benchmark: row.get_ref(0).unwrap().as_str().unwrap(),
243243
aid: row.get(1).unwrap(),
244244
error: row.get_ref(2).unwrap().try_into().unwrap(),
245245
})
246246
.unwrap();
247247
}
248248
}
249249

250-
struct ErrorSeries;
251-
252-
#[derive(Serialize)]
253-
struct ErrorSeriesRow<'a> {
254-
id: i32,
255-
krate: &'a str,
256-
}
257-
258-
impl Table for ErrorSeries {
259-
fn name() -> &'static str {
260-
"error_series"
261-
}
262-
263-
fn sqlite_attributes() -> &'static str {
264-
"id, crate"
265-
}
266-
267-
fn postgres_generated_id_attribute() -> Option<&'static str> {
268-
Some("id")
269-
}
270-
271-
fn write_postgres_csv_row<W: Write>(writer: &mut csv::Writer<W>, row: &rusqlite::Row) {
272-
writer
273-
.serialize(ErrorSeriesRow {
274-
id: row.get(0).unwrap(),
275-
krate: row.get_ref(1).unwrap().as_str().unwrap(),
276-
})
277-
.unwrap();
278-
}
279-
}
280-
281250
struct Pstat;
282251

283252
#[derive(Serialize)]
@@ -664,7 +633,6 @@ async fn main() -> anyhow::Result<()> {
664633
copy::<Benchmark>(&sqlite_tx, &postgres_tx).await;
665634
copy::<Collection>(&sqlite_tx, &postgres_tx).await;
666635
copy::<CollectorProgress>(&sqlite_tx, &postgres_tx).await;
667-
copy::<ErrorSeries>(&sqlite_tx, &postgres_tx).await;
668636
copy::<Error>(&sqlite_tx, &postgres_tx).await;
669637
copy::<PstatSeries>(&sqlite_tx, &postgres_tx).await;
670638
copy::<Pstat>(&sqlite_tx, &postgres_tx).await;

0 commit comments

Comments
 (0)