Skip to content

Commit 9da5493

Browse files
committed
node: Remove unused code from manager::deployment
1 parent 57c5442 commit 9da5493

File tree

1 file changed

+3
-105
lines changed

1 file changed

+3
-105
lines changed

node/src/manager/deployment.rs

+3-105
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ use graph::{
1111
components::store::DeploymentLocator,
1212
data::subgraph::status,
1313
prelude::{
14-
anyhow::{self, anyhow, bail},
15-
lazy_static, DeploymentHash, Error, SubgraphStore as _,
14+
anyhow::{self},
15+
lazy_static, DeploymentHash,
1616
},
1717
};
18+
use graph_store_postgres::command_support::catalog as store_catalog;
1819
use graph_store_postgres::connection_pool::ConnectionPool;
19-
use graph_store_postgres::{command_support::catalog as store_catalog, Shard, SubgraphStore};
2020

21-
use crate::manager::deployment;
2221
use crate::manager::display::List;
2322

2423
lazy_static! {
@@ -156,50 +155,6 @@ pub struct Deployment {
156155
}
157156

158157
impl Deployment {
159-
pub fn lookup(primary: &ConnectionPool, name: &str) -> Result<Vec<Self>, anyhow::Error> {
160-
let conn = primary.get()?;
161-
Self::lookup_with_conn(&conn, name)
162-
}
163-
164-
pub fn lookup_with_conn(conn: &PgConnection, name: &str) -> Result<Vec<Self>, anyhow::Error> {
165-
use store_catalog::deployment_schemas as ds;
166-
use store_catalog::subgraph as s;
167-
use store_catalog::subgraph_deployment_assignment as a;
168-
use store_catalog::subgraph_version as v;
169-
170-
let query = ds::table
171-
.inner_join(v::table.on(v::deployment.eq(ds::subgraph)))
172-
.inner_join(s::table.on(v::subgraph.eq(s::id)))
173-
.left_outer_join(a::table.on(a::id.eq(ds::id)))
174-
.select((
175-
s::name,
176-
sql::<Text>(
177-
"(case
178-
when subgraphs.subgraph.pending_version = subgraphs.subgraph_version.id then 'pending'
179-
when subgraphs.subgraph.current_version = subgraphs.subgraph_version.id then 'current'
180-
else 'unused' end) status",
181-
),
182-
v::deployment,
183-
ds::name,
184-
ds::id,
185-
a::node_id.nullable(),
186-
ds::shard,
187-
ds::network,
188-
ds::active,
189-
));
190-
191-
let deployments: Vec<Deployment> = if name.starts_with("sgd") {
192-
query.filter(ds::name.eq(&name)).load(conn)?
193-
} else if name.starts_with("Qm") {
194-
query.filter(ds::subgraph.eq(&name)).load(conn)?
195-
} else {
196-
// A subgraph name
197-
let pattern = format!("%{}%", name);
198-
query.filter(s::name.ilike(&pattern)).load(conn)?
199-
};
200-
Ok(deployments)
201-
}
202-
203158
pub fn locator(&self) -> DeploymentLocator {
204159
DeploymentLocator::new(
205160
DeploymentId(self.id),
@@ -262,60 +217,3 @@ impl Deployment {
262217
list.render();
263218
}
264219
}
265-
266-
pub fn locate(
267-
store: &SubgraphStore,
268-
hash: String,
269-
shard: Option<String>,
270-
) -> Result<DeploymentLocator, Error> {
271-
let hash = deployment::as_hash(hash)?;
272-
273-
fn locate_unique(store: &SubgraphStore, hash: String) -> Result<DeploymentLocator, Error> {
274-
let locators = store.locators(&hash)?;
275-
276-
match locators.len() {
277-
0 => {
278-
bail!("no matching assignment");
279-
}
280-
1 => Ok(locators[0].clone()),
281-
_ => {
282-
bail!(
283-
"deployment hash `{}` is ambiguous: {} locations found",
284-
hash,
285-
locators.len()
286-
);
287-
}
288-
}
289-
}
290-
291-
match shard {
292-
Some(shard) => store
293-
.locate_in_shard(&hash, Shard::new(shard.clone())?)?
294-
.ok_or_else(|| anyhow!("no deployment with hash `{}` in shard {}", hash, shard)),
295-
None => locate_unique(store, hash.to_string()),
296-
}
297-
}
298-
299-
pub fn as_hash(hash: String) -> Result<DeploymentHash, Error> {
300-
DeploymentHash::new(hash).map_err(|s| anyhow!("illegal deployment hash `{}`", s))
301-
}
302-
303-
/// Finds a single deployment locator for the given deployment identifier.
304-
pub fn find_single_deployment_locator(
305-
pool: &ConnectionPool,
306-
name: &str,
307-
) -> anyhow::Result<DeploymentLocator> {
308-
let mut locators: Vec<DeploymentLocator> = HashSet::<DeploymentLocator>::from_iter(
309-
Deployment::lookup(pool, name)?
310-
.into_iter()
311-
.map(|deployment| deployment.locator()),
312-
)
313-
.into_iter()
314-
.collect();
315-
let deployment_locator = match locators.len() {
316-
0 => anyhow::bail!("Found no deployment for `{}`", name),
317-
1 => locators.pop().unwrap(),
318-
n => anyhow::bail!("Found {} deployments for `{}`", n, name),
319-
};
320-
Ok(deployment_locator)
321-
}

0 commit comments

Comments
 (0)