Skip to content

Commit

Permalink
remove unused db mod from site
Browse files Browse the repository at this point in the history
  • Loading branch information
s7tya committed Aug 5, 2024
1 parent b55fe76 commit d057abb
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion site/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! comparison endpoints
use crate::api;
use crate::db::{ArtifactId, Benchmark, Lookup, Profile, Scenario};
use crate::github;
use crate::load::SiteCtxt;

Expand All @@ -13,6 +12,7 @@ use database::{
comparison::Metric,
selector::{self, BenchmarkQuery, CompileBenchmarkQuery, RuntimeBenchmarkQuery, TestCase},
};
use database::{ArtifactId, Benchmark, Lookup, Profile, Scenario};
use serde::Serialize;

use crate::api::comparison::CompileBenchmarkMetadata;
Expand Down
2 changes: 0 additions & 2 deletions site/src/db.rs

This file was deleted.

1 change: 0 additions & 1 deletion site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
extern crate itertools;

pub mod api;
pub mod db;
pub mod github;
pub mod load;
pub mod server;
Expand Down
15 changes: 7 additions & 8 deletions site/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use parking_lot::Mutex;
use regex::Regex;
use serde::{Deserialize, Serialize};

use crate::db;
use crate::self_profile::SelfProfileCache;
use collector::compile::benchmark::category::Category;
use collector::{Bound, MasterCommit};
Expand Down Expand Up @@ -128,7 +127,7 @@ pub struct SiteCtxt {
/// Cached site landing page
pub landing_page: ArcSwap<Option<Arc<crate::api::graphs::Response>>>,
/// Index of various common queries
pub index: ArcSwap<crate::db::Index>,
pub index: ArcSwap<database::Index>,
/// Cached master-branch Rust commits
pub master_commits: Arc<ArcSwap<MasterCommitCache>>, // outer Arc enables mutation in background task
/// Cache for self profile data
Expand All @@ -138,12 +137,12 @@ pub struct SiteCtxt {
}

impl SiteCtxt {
pub fn summary_scenarios(&self) -> Vec<crate::db::Scenario> {
pub fn summary_scenarios(&self) -> Vec<database::Scenario> {
vec![
crate::db::Scenario::Empty,
crate::db::Scenario::IncrementalEmpty,
crate::db::Scenario::IncrementalFresh,
crate::db::Scenario::IncrementalPatch("println".into()),
database::Scenario::Empty,
database::Scenario::IncrementalEmpty,
database::Scenario::IncrementalFresh,
database::Scenario::IncrementalPatch("println".into()),
]
}

Expand All @@ -160,7 +159,7 @@ impl SiteCtxt {
let pool = Pool::open(db_url);

let mut conn = pool.connection().await;
let index = db::Index::load(&mut *conn).await;
let index = database::Index::load(&mut *conn).await;

let config = if let Ok(s) = fs::read_to_string("site-config.toml") {
toml::from_str(&s)?
Expand Down
2 changes: 1 addition & 1 deletion site/src/request_handlers/bootstrap.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use futures::stream::{FuturesOrdered, StreamExt};

use crate::api::{bootstrap, ServerResult};
use crate::db::ArtifactId;
use crate::load::SiteCtxt;
use database::ArtifactId;

use std::time::Duration;

Expand Down
8 changes: 4 additions & 4 deletions site/src/request_handlers/dashboard.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;

use database::selector;
use lazy_static::lazy_static;

use crate::api::{dashboard, ServerResult};
use crate::benchmark_metadata::get_stable_benchmark_names;
use crate::db::{self, comparison::Metric, ArtifactId, Profile, Scenario};
use crate::load::SiteCtxt;
use database::selector;
use database::{self, comparison::Metric, ArtifactId, Profile, Scenario};

pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Response> {
let index = ctxt.index.load();
Expand Down Expand Up @@ -104,7 +104,7 @@ pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Re
)
.await?;

let points = db::average(
let points = crate::average::average(
responses
.into_iter()
.map(|sr| sr.interpolate().series)
Expand Down Expand Up @@ -139,7 +139,7 @@ pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Re

// The flag is used to ignore only the initial values where the runtime benchmark was not implemented.
let mut ignore_runtime_benchmark = true;
let points = db::average(
let points = crate::average::average(
responses
.into_iter()
.map(|sr| sr.interpolate().series)
Expand Down
6 changes: 3 additions & 3 deletions site/src/request_handlers/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use collector::Bound;
use crate::api::detail_sections::CompilationSections;
use crate::api::graphs::GraphKind;
use crate::api::{detail_graphs, detail_sections, graphs, runtime_detail_graphs, ServerResult};
use crate::db::{self, ArtifactId, Profile, Scenario};
use crate::load::SiteCtxt;
use crate::self_profile::get_or_download_self_profile;

use database::interpolate::IsInterpolated;
use database::selector::{
CompileBenchmarkQuery, CompileTestCase, RuntimeBenchmarkQuery, Selector, SeriesResponse,
};
use database::{self, ArtifactId, Profile, Scenario};

/// Returns data for before/after graphs when comparing a single test result comparison
/// for a compile-time benchmark.
Expand Down Expand Up @@ -321,7 +321,7 @@ fn create_summary(
.map(|sr| sr.series.iter().cloned())
.collect();

let value = db::average(baseline_responses)
let value = crate::average::average(baseline_responses)
.next()
.map_or(0.0, |((_c, d), _interpolated)| d.expect("interpolated"));
*v.insert(value)
Expand All @@ -338,7 +338,7 @@ fn create_summary(
.map(|sr| sr.series.iter().cloned())
.collect();

let avg_vs_baseline = db::average(summary_case_responses)
let avg_vs_baseline = crate::average::average(summary_case_responses)
.map(|((c, d), i)| ((c, Some(d.expect("interpolated") / baseline)), i));

let graph_series = graph_series(avg_vs_baseline, graph_kind);
Expand Down
2 changes: 1 addition & 1 deletion site/src/request_handlers/self_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use std::time::Instant;

use bytes::Buf;
use database::selector;
use database::ArtifactId;
use database::{comparison::Metric, CommitType};
use headers::{ContentType, Header};
use hyper::StatusCode;

use crate::api::self_profile::ArtifactSizeDelta;
use crate::api::{self_profile, self_profile_processed, self_profile_raw, ServerResult};
use crate::db::ArtifactId;
use crate::load::SiteCtxt;
use crate::self_profile::{get_or_download_self_profile, get_self_profile_raw_data};
use crate::server::{Response, ResponseHeaders};
Expand Down
3 changes: 2 additions & 1 deletion site/src/request_handlers/status_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use std::sync::Arc;

use crate::api::status;
use crate::api::status::FinishedRun;
use crate::db::{ArtifactId, Lookup};
use crate::load::SiteCtxt;

use database::{ArtifactId, Lookup};

// How many historical (finished) runs should be returned from the status API.
const FINISHED_RUN_COUNT: u64 = 5;

Expand Down
2 changes: 1 addition & 1 deletion site/src/selector.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::db::ArtifactId;
use crate::load::SiteCtxt;

use collector::Bound;
use database::selector::StatisticSeries;
use database::selector::{BenchmarkQuery, SeriesResponse};
use database::ArtifactId;
use database::{Commit, Index};

use std::ops::RangeInclusive;
Expand Down
5 changes: 3 additions & 2 deletions site/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ pub use crate::api::{
self, bootstrap, comparison, dashboard, github, graphs, info, self_profile, self_profile_raw,
status, triage, ServerResult,
};
use crate::db::{self, ArtifactId};
use crate::load::{Config, SiteCtxt};
use crate::request_handlers;
use crate::resources::{Payload, ResourceResolver};

use database::{self, ArtifactId};

pub type Request = http::Request<hyper::Body>;
pub type Response = http::Response<hyper::Body>;

Expand Down Expand Up @@ -295,7 +296,7 @@ impl Server {
let ctxt: Arc<SiteCtxt> = self.ctxt.read().as_ref().unwrap().clone();
let _updating = self.updating.release_on_drop(channel);
let mut conn = ctxt.conn().await;
let index = db::Index::load(&mut *conn).await;
let index = database::Index::load(&mut *conn).await;
eprintln!("index has {} commits", index.commits().len());
ctxt.index.store(Arc::new(index));

Expand Down

0 comments on commit d057abb

Please sign in to comment.