Skip to content

Commit

Permalink
rename data_sets table to hex_assignments_data_set_status
Browse files Browse the repository at this point in the history
  • Loading branch information
maplant committed May 20, 2024
1 parent 8ebb8c1 commit c1a3f96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mobile_verifier/migrations/33_data_sets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CREATE TYPE data_set_type AS enum (
'landtype'
);

CREATE TABLE IF NOT EXISTS data_sets (
CREATE TABLE IF NOT EXISTS hex_assignment_data_set_status (
filename TEXT PRIMARY KEY,
data_set data_set_type NOT NULL,
time_to_use TIMESTAMPTZ NOT NULL,
Expand Down
14 changes: 7 additions & 7 deletions mobile_verifier/src/boosting_oracles/data_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ pub mod db {
pool: &PgPool,
data_set_type: DataSetType,
) -> sqlx::Result<Option<DateTime<Utc>>> {
sqlx::query_scalar("SELECT time_to_use FROM data_sets WHERE data_set = $1 ORDER BY time_to_use DESC LIMIT 1")
sqlx::query_scalar("SELECT time_to_use FROM hex_assignment_data_set_status WHERE data_set = $1 ORDER BY time_to_use DESC LIMIT 1")
.bind(data_set_type)
.fetch_optional(pool)
.await
Expand All @@ -458,7 +458,7 @@ pub mod db {
) -> sqlx::Result<()> {
sqlx::query(
r#"
INSERT INTO data_sets (filename, data_set, time_to_use, status)
INSERT INTO hex_assignment_data_set_status (filename, data_set, time_to_use, status)
VALUES ($1, $2, $3, 'pending')
ON CONFLICT DO NOTHING
"#,
Expand All @@ -477,7 +477,7 @@ pub mod db {
since: Option<DateTime<Utc>>,
) -> sqlx::Result<Option<NewDataSet>> {
sqlx::query_as(
"SELECT filename, time_to_use, status FROM data_sets WHERE status != 'processed' AND data_set = $1 AND COALESCE(time_to_use > $2, TRUE) AND time_to_use <= $3 ORDER BY time_to_use DESC LIMIT 1"
"SELECT filename, time_to_use, status FROM hex_assignment_data_set_status WHERE status != 'processed' AND data_set = $1 AND COALESCE(time_to_use > $2, TRUE) AND time_to_use <= $3 ORDER BY time_to_use DESC LIMIT 1"
)
.bind(data_set_type)
.bind(since)
Expand All @@ -491,7 +491,7 @@ pub mod db {
data_set_type: DataSetType,
) -> sqlx::Result<Option<NewDataSet>> {
sqlx::query_as(
"SELECT filename, time_to_use, status FROM data_sets WHERE status = 'processed' AND data_set = $1 ORDER BY time_to_use DESC LIMIT 1"
"SELECT filename, time_to_use, status FROM hex_assignment_data_set_status WHERE status = 'processed' AND data_set = $1 ORDER BY time_to_use DESC LIMIT 1"
)
.bind(data_set_type)
.fetch_optional(pool)
Expand All @@ -503,7 +503,7 @@ pub mod db {
filename: &str,
status: DataSetStatus,
) -> sqlx::Result<()> {
sqlx::query("UPDATE data_sets SET status = $1 WHERE filename = $2")
sqlx::query("UPDATE hex_assignment_data_set_status SET status = $1 WHERE filename = $2")
.bind(status)
.bind(filename)
.execute(pool)
Expand All @@ -516,7 +516,7 @@ pub mod db {
data_set_type: DataSetType,
) -> sqlx::Result<Option<DateTime<Utc>>> {
sqlx::query_scalar(
"SELECT time_to_use FROM data_sets WHERE status = 'processed' AND data_set = $1 ORDER BY time_to_use DESC LIMIT 1"
"SELECT time_to_use FROM hex_assignment_data_set_status WHERE status = 'processed' AND data_set = $1 ORDER BY time_to_use DESC LIMIT 1"
)
.bind(data_set_type)
.fetch_optional(pool)
Expand All @@ -529,7 +529,7 @@ pub mod db {
period_end: DateTime<Utc>,
) -> sqlx::Result<bool> {
Ok(sqlx::query_scalar(
"SELECT COUNT(*) > 0 FROM data_sets WHERE time_to_use <= $1 AND status != 'processed'",
"SELECT COUNT(*) > 0 FROM hex_assignment_data_set_status WHERE time_to_use <= $1 AND status != 'processed'",
)
.bind(period_end)
.fetch_one(pool)
Expand Down

0 comments on commit c1a3f96

Please sign in to comment.