Skip to content

Commit 77fc1fd

Browse files
committed
support runtime_pstat, runtime_pstat_series, artifact_size (postgres to sqlite)
1 parent 7d76ee3 commit 77fc1fd

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,87 @@ impl Table for RustcCompilation {
358358
}
359359
}
360360

361+
struct RuntimePstat;
362+
363+
impl Table for RuntimePstat {
364+
fn name(&self) -> &'static str {
365+
"runtime_pstat"
366+
}
367+
368+
fn postgres_select_statement(&self, since_weeks_ago: Option<u32>) -> String {
369+
let s = "select series, aid, cid, value from ".to_string() + self.name();
370+
with_filter_clause_maybe(s, ARTIFACT_JOIN_AND_WHERE, since_weeks_ago)
371+
}
372+
373+
fn sqlite_insert_statement(&self) -> &'static str {
374+
"insert into runtime_pstat (series, aid, cid, value) VALUES (?, ?, ?, ?)"
375+
}
376+
377+
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
378+
statement
379+
.execute(params![
380+
row.get::<_, i32>(0),
381+
row.get::<_, i32>(1),
382+
row.get::<_, i32>(2),
383+
row.get::<_, f64>(3),
384+
])
385+
.unwrap();
386+
}
387+
}
388+
389+
struct RuntimePstatSeries;
390+
391+
impl Table for RuntimePstatSeries {
392+
fn name(&self) -> &'static str {
393+
"runtime_pstat_series"
394+
}
395+
396+
fn postgres_select_statement(&self, _since_weeks_ago: Option<u32>) -> String {
397+
"select id, benchmark, metric from ".to_string() + self.name()
398+
}
399+
400+
fn sqlite_insert_statement(&self) -> &'static str {
401+
"insert into runtime_pstat_series (id, benchmark, metric) VALUES (?, ?, ?)"
402+
}
403+
404+
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
405+
statement
406+
.execute(params![
407+
row.get::<_, i32>(0),
408+
row.get::<_, &str>(1),
409+
row.get::<_, &str>(2),
410+
])
411+
.unwrap();
412+
}
413+
}
414+
415+
struct ArtifactSize;
416+
417+
impl Table for ArtifactSize {
418+
fn name(&self) -> &'static str {
419+
"artifact_size"
420+
}
421+
422+
fn postgres_select_statement(&self, since_weeks_ago: Option<u32>) -> String {
423+
let s = "select aid, component, size from ".to_string() + self.name();
424+
with_filter_clause_maybe(s, ARTIFACT_JOIN_AND_WHERE, since_weeks_ago)
425+
}
426+
427+
fn sqlite_insert_statement(&self) -> &'static str {
428+
"insert into artifact_size (aid, component, size) VALUES (?, ?, ?)"
429+
}
430+
431+
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
432+
statement
433+
.execute(params![
434+
row.get::<_, i32>(0),
435+
row.get::<_, &str>(1),
436+
row.get::<_, i32>(2),
437+
])
438+
.unwrap();
439+
}
440+
}
441+
361442
#[tokio::main]
362443
async fn main() -> anyhow::Result<()> {
363444
env_logger::init();
@@ -375,6 +456,9 @@ async fn main() -> anyhow::Result<()> {
375456
&PullRequestBuild,
376457
&RawSelfProfile,
377458
&RustcCompilation,
459+
&RuntimePstatSeries,
460+
&RuntimePstat,
461+
&ArtifactSize,
378462
];
379463

380464
let table_names: Vec<_> = tables.iter().map(|table| table.name()).collect();

0 commit comments

Comments
 (0)