Skip to content

Commit 117ffa9

Browse files
committed
refactor: remove cache, use simple check
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 3559623 commit 117ffa9

13 files changed

+403
-298
lines changed

.sqlx/query-4129630725eb7f563f2b0532366d18653f57a9d4b6f231c00b9eea60392a0a6f.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.sqlx/query-842bde7fba1c7652b7cfc2dc568edc4204bbbd32aac6f7da7e99fb501ca5cc14.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-b54b1069daf03a377a0e7c09c9aa1732bb3638a3a4f942a665cf1fd38eb70c2d.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-d93dd26d7221c5e1ae15a919a2a651e43b6b9ffe9834df85a62707d3a2d051b4.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-dcc710ebd4fa7a86f95a45ebf13bc7c298006af22134c144048b0ac7183353c0.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-e14503b633fc673b65448e70c204651cfd94b4b82f26baf0755efa80e6045c0a.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-ef6affb9039ad19a69f4a5116d7893b4f7209c985c367215b2eed25adc78c462.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/cost_model.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use thegraph_core::{DeploymentId, ParseDeploymentIdError};
1212
/// These can have "global" as the deployment ID.
1313
#[derive(Debug, Clone)]
1414
pub(crate) struct DbCostModel {
15-
pub deployment: Option<String>,
15+
pub deployment: String,
1616
pub model: Option<String>,
1717
pub variables: Option<Value>,
1818
}
@@ -32,7 +32,7 @@ impl TryFrom<DbCostModel> for CostModel {
3232

3333
fn try_from(db_model: DbCostModel) -> Result<Self, Self::Error> {
3434
Ok(Self {
35-
deployment: DeploymentId::from_str(&db_model.deployment.unwrap())?,
35+
deployment: DeploymentId::from_str(&db_model.deployment)?,
3636
model: db_model.model,
3737
variables: db_model.variables,
3838
})
@@ -43,7 +43,7 @@ impl From<CostModel> for DbCostModel {
4343
fn from(model: CostModel) -> Self {
4444
let deployment = model.deployment;
4545
DbCostModel {
46-
deployment: Some(format!("{deployment:#x}")),
46+
deployment: format!("{deployment:#x}"),
4747
model: model.model,
4848
variables: model.variables,
4949
}
@@ -164,7 +164,7 @@ pub async fn cost_model(
164164
}
165165

166166
/// Query global cost model
167-
async fn global_cost_model(pool: &PgPool) -> Result<Option<DbCostModel>, anyhow::Error> {
167+
pub(crate) async fn global_cost_model(pool: &PgPool) -> Result<Option<DbCostModel>, anyhow::Error> {
168168
sqlx::query_as!(
169169
DbCostModel,
170170
r#"
@@ -200,7 +200,7 @@ pub(crate) mod test {
200200
for model in models {
201201
sqlx::query!(
202202
r#"
203-
INSERT INTO "CostModelsHistory" (deployment, model)
203+
INSERT INTO "CostModels" (deployment, model)
204204
VALUES ($1, $2);
205205
"#,
206206
model.deployment,
@@ -216,9 +216,9 @@ pub(crate) mod test {
216216
models.into_iter().map(DbCostModel::from).collect()
217217
}
218218

219-
fn global_cost_model() -> DbCostModel {
219+
pub fn global_cost_model() -> DbCostModel {
220220
DbCostModel {
221-
deployment: Some("global".to_string()),
221+
deployment: "global".to_string(),
222222
model: Some("default => 0.00001;".to_string()),
223223
variables: None,
224224
}

0 commit comments

Comments
 (0)