Skip to content

Commit 27d5e15

Browse files
committed
Rename InputData to SiteCtxt
1 parent d05d0a7 commit 27d5e15

File tree

7 files changed

+51
-51
lines changed

7 files changed

+51
-51
lines changed

site/src/comparison.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use crate::api;
66
use crate::db::{self, ArtifactId, Cache, Crate, Profile};
7-
use crate::load::InputData;
7+
use crate::load::SiteCtxt;
88
use crate::selector::{self, Tag};
99

1010
use collector::Bound;
@@ -18,7 +18,7 @@ type BoxedError = Box<dyn Error + Send + Sync>;
1818

1919
pub async fn handle_triage(
2020
body: api::triage::Request,
21-
data: &InputData,
21+
data: &SiteCtxt,
2222
) -> Result<api::triage::Response, BoxedError> {
2323
let start = body.start;
2424
let end = body.end;
@@ -84,7 +84,7 @@ pub async fn handle_triage(
8484

8585
pub async fn handle_compare(
8686
body: api::comparison::Request,
87-
data: &InputData,
87+
data: &SiteCtxt,
8888
) -> Result<api::comparison::Response, BoxedError> {
8989
let master_commits = collector::master_commits().await?;
9090
let end = body.end;
@@ -241,7 +241,7 @@ pub async fn compare(
241241
start: Bound,
242242
end: Bound,
243243
stat: String,
244-
data: &InputData,
244+
data: &SiteCtxt,
245245
) -> Result<Option<Comparison>, BoxedError> {
246246
let master_commits = collector::master_commits().await?;
247247
compare_given_commits(start, end, stat, data, &master_commits).await
@@ -252,7 +252,7 @@ pub async fn compare_given_commits(
252252
start: Bound,
253253
end: Bound,
254254
stat: String,
255-
data: &InputData,
255+
data: &SiteCtxt,
256256
master_commits: &[collector::MasterCommit],
257257
) -> Result<Option<Comparison>, BoxedError> {
258258
let a = data

site/src/github.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::api::{github, ServerResult};
22
use crate::comparison::{ComparisonSummary, Direction};
3-
use crate::load::{Config, InputData, TryCommit};
3+
use crate::load::{Config, SiteCtxt, TryCommit};
44
use anyhow::Context as _;
55
use hashbrown::HashSet;
66
use serde::Deserialize;
@@ -39,7 +39,7 @@ async fn get_authorized_users() -> ServerResult<Vec<usize>> {
3939

4040
pub async fn handle_github(
4141
request: github::Request,
42-
data: Arc<InputData>,
42+
data: Arc<SiteCtxt>,
4343
) -> ServerResult<github::Response> {
4444
if request.comment.body.contains(" homu: ") {
4545
if let Some(sha) = handle_homu_res(&request).await {
@@ -152,7 +152,7 @@ pub async fn handle_github(
152152
// Returns the PR number
153153
async fn pr_and_try_for_rollup(
154154
client: &reqwest::Client,
155-
data: Arc<InputData>,
155+
data: Arc<SiteCtxt>,
156156
repository_url: &str,
157157
rollup_merge_sha: &str,
158158
origin_url: &str,
@@ -231,7 +231,7 @@ struct RollupBranch {
231231

232232
async fn branch_for_rollup(
233233
client: &reqwest::Client,
234-
data: &InputData,
234+
data: &SiteCtxt,
235235
repository_url: &str,
236236
rollup_merge_sha: &str,
237237
) -> anyhow::Result<RollupBranch> {
@@ -328,7 +328,7 @@ struct CreateRefRequest<'a> {
328328

329329
pub async fn create_ref(
330330
client: &reqwest::Client,
331-
data: &InputData,
331+
data: &SiteCtxt,
332332
repository_url: &str,
333333
ref_: &str,
334334
sha: &str,
@@ -375,7 +375,7 @@ pub struct CreatePrResponse {
375375

376376
pub async fn create_pr(
377377
client: &reqwest::Client,
378-
data: &InputData,
378+
data: &SiteCtxt,
379379
repository_url: &str,
380380
title: &str,
381381
head: &str,
@@ -423,7 +423,7 @@ struct CreateCommitResponse {
423423

424424
pub async fn create_commit(
425425
client: &reqwest::Client,
426-
data: &InputData,
426+
data: &SiteCtxt,
427427
repository_url: &str,
428428
message: &str,
429429
tree: &str,
@@ -461,7 +461,7 @@ pub async fn create_commit(
461461

462462
pub async fn get_commit(
463463
client: &reqwest::Client,
464-
data: &InputData,
464+
data: &SiteCtxt,
465465
repository_url: &str,
466466
sha: &str,
467467
) -> anyhow::Result<github::Commit> {
@@ -497,7 +497,7 @@ pub async fn get_commit(
497497

498498
async fn enqueue_sha(
499499
request: github::Request,
500-
data: &InputData,
500+
data: &SiteCtxt,
501501
commit: String,
502502
) -> ServerResult<github::Response> {
503503
let client = reqwest::Client::new();
@@ -592,7 +592,7 @@ where
592592
}
593593
}
594594

595-
pub async fn post_finished(data: &InputData) {
595+
pub async fn post_finished(data: &SiteCtxt) {
596596
// If the github token is not configured, do not run this -- we don't want
597597
// to mark things as complete without posting the comment.
598598
if data.config.keys.github.is_none() {
@@ -681,7 +681,7 @@ for rolling up. {}
681681

682682
async fn categorize_benchmark(
683683
commit: &database::QueuedCommit,
684-
data: &InputData,
684+
data: &SiteCtxt,
685685
) -> (String, Option<Direction>) {
686686
let comparison = match crate::comparison::compare(
687687
collector::Bound::Commit(commit.parent_sha.clone()),

site/src/load.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub struct Config {
8282
}
8383

8484
/// Site context object that contains global data
85-
pub struct InputData {
85+
pub struct SiteCtxt {
8686
/// Site configuration
8787
pub config: Config,
8888
/// Cached site landing page
@@ -93,7 +93,7 @@ pub struct InputData {
9393
pub pool: Pool,
9494
}
9595

96-
impl InputData {
96+
impl SiteCtxt {
9797
pub fn summary_patches(&self) -> Vec<crate::db::Cache> {
9898
vec![
9999
crate::db::Cache::Empty,
@@ -111,9 +111,9 @@ impl InputData {
111111
crate::selector::range_subset(self.index.load().commits(), range)
112112
}
113113

114-
/// Initialize `InputData from the file system.
115-
pub async fn from_fs(db: &str) -> anyhow::Result<InputData> {
116-
if Path::new(db).join("times").exists() {
114+
/// Initialize `SiteCtxt` from database url
115+
pub async fn from_db_url(db_url: &str) -> anyhow::Result<Self> {
116+
if Path::new(db_url).join("times").exists() {
117117
eprintln!("It looks like you're running the site off of the old data format");
118118
eprintln!(
119119
"Please utilize the ingest-json script to convert the data into the new database format."
@@ -125,7 +125,7 @@ impl InputData {
125125
std::process::exit(1);
126126
}
127127

128-
let pool = Pool::open(db);
128+
let pool = Pool::open(db_url);
129129

130130
let mut conn = pool.connection().await;
131131
let index = db::Index::load(&mut *conn).await;
@@ -141,7 +141,7 @@ impl InputData {
141141
}
142142
};
143143

144-
Ok(InputData {
144+
Ok(Self {
145145
config,
146146
index: ArcSwap::new(Arc::new(index)),
147147
pool,

site/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async fn main() {
2626
#[cfg(unix)]
2727
let _ = jemalloc_ctl::background_thread::write(true);
2828

29-
let data: Arc<RwLock<Option<Arc<load::InputData>>>> = Arc::new(RwLock::new(None));
29+
let data: Arc<RwLock<Option<Arc<load::SiteCtxt>>>> = Arc::new(RwLock::new(None));
3030
let data_ = data.clone();
3131
let db_url = env::var("DATABASE_URL")
3232
.ok()
@@ -37,7 +37,7 @@ async fn main() {
3737
});
3838
let fut = tokio::task::spawn_blocking(move || {
3939
tokio::task::spawn(async move {
40-
let res = Arc::new(load::InputData::from_fs(&db_url).await.unwrap());
40+
let res = Arc::new(load::SiteCtxt::from_db_url(&db_url).await.unwrap());
4141
*data_.write() = Some(res.clone());
4242
let commits = res.index.load().commits().len();
4343
let artifacts = res.index.load().artifacts().count();

site/src/selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
use crate::db::{ArtifactId, Cache, Profile};
2626
use crate::interpolate::Interpolate;
27-
use crate::load::InputData as Db;
27+
use crate::load::SiteCtxt as Db;
2828
use async_trait::async_trait;
2929
use collector::Bound;
3030
use database::{Commit, Crate, Index, Lookup, ProcessStatistic, QueryLabel};

site/src/self_profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module handles self-profile "rich" APIs (e.g., chrome profiler JSON)
22
//! generation from the raw artifacts on demand.
33
4-
use crate::load::InputData;
4+
use crate::load::SiteCtxt;
55
use anyhow::Context;
66
use bytes::Buf;
77
use hyper::StatusCode;
@@ -67,7 +67,7 @@ impl fmt::Debug for Pieces {
6767

6868
pub async fn get_pieces(
6969
body: crate::api::self_profile_raw::Request,
70-
data: &InputData,
70+
data: &SiteCtxt,
7171
) -> Result<Pieces, Response> {
7272
let res = crate::server::handle_self_profile_raw(body, data).await;
7373
let url = match res {

0 commit comments

Comments
 (0)