Skip to content

Commit 053570c

Browse files
committed
fix build
1 parent c8467d9 commit 053570c

File tree

4 files changed

+41
-31
lines changed

4 files changed

+41
-31
lines changed

Cargo.lock

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

src/vit-servicing-station/vit-servicing-station-lib/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ license = "MIT OR Apache-2.0"
1111
async-trait = "0.1.33"
1212
base64 = "0.13"
1313
time = { version = "0.3", features = ["parsing", "formatting"] }
14-
diesel = { version = "1.4.5", features = ["postgres", "r2d2", "64-column-tables", "serde_json"] }
15-
diesel_migrations = "1.4.0"
14+
diesel = { version = "1.4.8", features = ["postgres", "r2d2", "64-column-tables", "chrono"] }
1615
dotenv = "0.15"
1716
itertools = "0.10"
1817
log = { version = "0.4.11", features = ["serde"] }

src/vit-servicing-station/vit-servicing-station-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ hex = "0.4.2"
1212
base64 = "0.13"
1313
cfg-if = "0.1"
1414
time = { version = "0.3", features = ["formatting", "parsing", "macros"] }
15-
diesel = { version = "1.4.4", features = ["postgres", "r2d2", "chrono"] }
15+
diesel = { version = "1.4.8", features = ["postgres", "r2d2", "64-column-tables", "chrono", "serde_json"] }
1616
serde = { version = "1.0", features = ["derive"] }
1717
serde_json = "1.0.53"
1818
clap = { workspace = true }

src/vit-servicing-station/vit-servicing-station-tests/src/common/db/mod.rs

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
use std::collections::BTreeMap;
22

3-
use diesel::RunQueryDsl;
3+
use diesel::{RunQueryDsl, row::NamedRow, deserialize::{self, FromSql}, backend::Backend, sql_types::Integer};
4+
5+
// Simple struct to receive row_id without derive macros to avoid non-local impl warnings
6+
struct RowId {
7+
row_id: i32,
8+
}
9+
10+
impl<DB> diesel::deserialize::QueryableByName<DB> for RowId
11+
where
12+
DB: Backend,
13+
i32: FromSql<Integer, DB>,
14+
{
15+
fn build<R: NamedRow<DB>>(row: &R) -> deserialize::Result<Self> {
16+
Ok(RowId {
17+
row_id: NamedRow::get(row, "row_id")?,
18+
})
19+
}
20+
}
421
use thiserror::Error;
522
use vit_servicing_station_lib::db::models::{
623
api_tokens::ApiTokenData,
@@ -11,11 +28,6 @@ use vit_servicing_station_lib::db::models::{
1128
};
1229
use vit_servicing_station_lib::db::DbConnection;
1330

14-
#[derive(diesel::QueryableByName)]
15-
struct RowId {
16-
#[sql_type = "diesel::sql_types::Integer"]
17-
row_id: i32,
18-
}
1931

2032
pub struct DbInserter<'a> {
2133
connection: &'a DbConnection,
@@ -199,60 +211,60 @@ impl<'a> DbInserter<'a> {
199211
.bind::<diesel::sql_types::Text, _>(&fund.fund_name)
200212
.bind::<diesel::sql_types::Text, _>(&fund.fund_goal)
201213
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
202-
chrono::NaiveDateTime::from_timestamp_millis(
214+
chrono::DateTime::from_timestamp_millis(
203215
fund.registration_snapshot_time * 1000,
204-
),
216+
).map(|dt| dt.naive_utc()),
205217
)
206218
.bind::<diesel::sql_types::BigInt, _>(fund.voting_power_threshold)
207219
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
208-
chrono::NaiveDateTime::from_timestamp_millis(fund.fund_start_time * 1000),
220+
chrono::DateTime::from_timestamp_millis(fund.fund_start_time * 1000).map(|dt| dt.naive_utc()),
209221
)
210222
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
211-
chrono::NaiveDateTime::from_timestamp_millis(fund.fund_end_time * 1000),
223+
chrono::DateTime::from_timestamp_millis(fund.fund_end_time * 1000).map(|dt| dt.naive_utc()),
212224
)
213225
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
214-
chrono::NaiveDateTime::from_timestamp_millis(
226+
chrono::DateTime::from_timestamp_millis(
215227
fund.stage_dates.insight_sharing_start * 1000,
216-
),
228+
).map(|dt| dt.naive_utc()),
217229
)
218230
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
219-
chrono::NaiveDateTime::from_timestamp_millis(
231+
chrono::DateTime::from_timestamp_millis(
220232
fund.stage_dates.proposal_submission_start * 1000,
221-
),
233+
).map(|dt| dt.naive_utc()),
222234
)
223235
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
224-
chrono::NaiveDateTime::from_timestamp_millis(
236+
chrono::DateTime::from_timestamp_millis(
225237
fund.stage_dates.refine_proposals_start * 1000,
226-
),
238+
).map(|dt| dt.naive_utc()),
227239
)
228240
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
229-
chrono::NaiveDateTime::from_timestamp_millis(
241+
chrono::DateTime::from_timestamp_millis(
230242
fund.stage_dates.finalize_proposals_start * 1000,
231-
),
243+
).map(|dt| dt.naive_utc()),
232244
)
233245
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
234-
chrono::NaiveDateTime::from_timestamp_millis(
246+
chrono::DateTime::from_timestamp_millis(
235247
fund.stage_dates.proposal_assessment_start * 1000,
236-
),
248+
).map(|dt| dt.naive_utc()),
237249
)
238250
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
239-
chrono::NaiveDateTime::from_timestamp_millis(
251+
chrono::DateTime::from_timestamp_millis(
240252
fund.stage_dates.assessment_qa_start * 1000,
241-
),
253+
).map(|dt| dt.naive_utc()),
242254
)
243255
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
244-
chrono::NaiveDateTime::from_timestamp_millis(
256+
chrono::DateTime::from_timestamp_millis(
245257
fund.stage_dates.snapshot_start * 1000,
246-
),
258+
).map(|dt| dt.naive_utc()),
247259
)
248260
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
249-
chrono::NaiveDateTime::from_timestamp_millis(fund.stage_dates.voting_start * 1000),
261+
chrono::DateTime::from_timestamp_millis(fund.stage_dates.voting_start * 1000).map(|dt| dt.naive_utc()),
250262
)
251263
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
252-
chrono::NaiveDateTime::from_timestamp_millis(fund.stage_dates.voting_end * 1000),
264+
chrono::DateTime::from_timestamp_millis(fund.stage_dates.voting_end * 1000).map(|dt| dt.naive_utc()),
253265
)
254266
.bind::<diesel::sql_types::Nullable<diesel::sql_types::Timestamp>, _>(
255-
chrono::NaiveDateTime::from_timestamp_millis(fund.stage_dates.tallying_end * 1000),
267+
chrono::DateTime::from_timestamp_millis(fund.stage_dates.tallying_end * 1000).map(|dt| dt.naive_utc()),
256268
)
257269
.bind::<diesel::sql_types::Jsonb, _>(serde_json::json!({
258270
"url": {

0 commit comments

Comments
 (0)