Skip to content

Commit

Permalink
Update operator_appstore_information migration
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Sep 10, 2024
1 parent 3125e94 commit 52202ad
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion apps/operator/src/appstore_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ impl AppstoreUpdater {
version: response.version,
ratings: response.user_rating_count,
average_rating: response.average_user_rating,
release_date: response.release_date.naive_utc(),
current_version_release_date: response.current_version_release_date.naive_utc(),
};
values.push(information);
values.push(information.clone());

println!("Update details. Found app: {}, language: {}", app.name, language.code);
}
Expand Down
1 change: 1 addition & 0 deletions crates/api_connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ version = { workspace = true }
[dependencies]
serde = { workspace = true }
reqwest = { workspace = true }
chrono = { workspace = true }
primitives = { path = "../primitives" }
3 changes: 3 additions & 0 deletions crates/api_connector/src/app_store_client/models.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::{DateTime, Utc};
use serde::Deserialize;
#[derive(Debug)]
pub enum AppStoreError {
Expand Down Expand Up @@ -25,6 +26,8 @@ pub struct App {
pub user_rating_count: Option<f64>,
pub average_user_rating: Option<f64>,
pub track_name: String,
pub release_date: DateTime<Utc>,
pub current_version_release_date: DateTime<Utc>,
}

#[derive(Debug, Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ ON operator_appstore_positions (store, app, keyword, country, (created_at::date)

CREATE TABLE IF NOT EXISTS operator_appstore_information (
id SERIAL PRIMARY KEY,
store VARCHAR(32) NOT NULL,
app VARCHAR(128) NOT NULL,
country VARCHAR(64) NOT NULL,
title VARCHAR(128) NOT NULL,
version VARCHAR(64) NOT NULL,
ratings FLOAT,
average_rating FLOAT,
updated_at TIMESTAMP NOT NULL DEFAULT current_timestamp,
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp
store VARCHAR(32) NOT NULL,
app VARCHAR(128) NOT NULL,
country VARCHAR(64) NOT NULL,
title VARCHAR(128) NOT NULL,
version VARCHAR(64) NOT NULL,
ratings FLOAT,
average_rating FLOAT,
release_date TIMESTAMP NOT NULL,
current_version_release_date TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT current_timestamp,
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp
);

CREATE UNIQUE INDEX uniq_store_app_country_date
Expand Down
4 changes: 4 additions & 0 deletions crates/storage/src/models/operator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::NaiveDateTime;
use diesel::prelude::*;
use serde::{Deserialize, Serialize};

Expand All @@ -23,6 +24,9 @@ pub struct AppStoreInformation {
pub version: String,
pub ratings: Option<f64>,
pub average_rating: Option<f64>,

pub release_date: NaiveDateTime,
pub current_version_release_date: NaiveDateTime,
}

#[derive(Debug, Queryable, Selectable, Insertable, AsChangeset, Serialize, Deserialize, Clone)]
Expand Down
22 changes: 12 additions & 10 deletions crates/storage/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ diesel::table! {
#[max_length = 16]
symbol -> Varchar,
decimals -> Int4,
enabled -> Bool,
rank -> Int4,
updated_at -> Timestamp,
created_at -> Timestamp,
rank -> Int4,
enabled -> Bool,
}
}

Expand Down Expand Up @@ -48,13 +48,13 @@ diesel::table! {
coinmarketcap -> Nullable<Varchar>,
#[max_length = 128]
discord -> Nullable<Varchar>,
updated_at -> Timestamp,
created_at -> Timestamp,
is_buyable -> Bool,
is_sellable -> Bool,
is_swappable -> Bool,
is_stakeable -> Bool,
staking_apr -> Nullable<Float8>,
updated_at -> Timestamp,
created_at -> Timestamp,
}
}

Expand Down Expand Up @@ -89,12 +89,12 @@ diesel::table! {
#[max_length = 8]
locale -> Varchar,
#[max_length = 8]
currency -> Varchar,
#[max_length = 8]
version -> Varchar,
subscriptions_version -> Int4,
updated_at -> Timestamp,
created_at -> Timestamp,
#[max_length = 8]
currency -> Varchar,
subscriptions_version -> Int4,
}
}

Expand All @@ -115,9 +115,9 @@ diesel::table! {
#[max_length = 128]
token_id -> Nullable<Varchar>,
enabled -> Bool,
hidden -> Bool,
updated_at -> Timestamp,
created_at -> Timestamp,
hidden -> Bool,
}
}

Expand Down Expand Up @@ -198,6 +198,8 @@ diesel::table! {
version -> Varchar,
ratings -> Nullable<Float8>,
average_rating -> Nullable<Float8>,
release_date -> Timestamp,
current_version_release_date -> Timestamp,
updated_at -> Timestamp,
created_at -> Timestamp,
}
Expand Down Expand Up @@ -311,12 +313,12 @@ diesel::table! {
subscriptions (id) {
id -> Int4,
device_id -> Int4,
wallet_index -> Int4,
chain -> Varchar,
#[max_length = 256]
address -> Varchar,
updated_at -> Timestamp,
created_at -> Timestamp,
wallet_index -> Int4,
}
}

Expand Down Expand Up @@ -371,10 +373,10 @@ diesel::table! {
fee -> Nullable<Varchar>,
utxo_inputs -> Nullable<Jsonb>,
utxo_outputs -> Nullable<Jsonb>,
metadata -> Nullable<Jsonb>,
fee_asset_id -> Varchar,
updated_at -> Timestamp,
created_at -> Timestamp,
metadata -> Nullable<Jsonb>,
}
}

Expand Down

0 comments on commit 52202ad

Please sign in to comment.