This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::view::loading::LoadingSpinnerGrayNoVh; | |
use crate::Route; | |
use gloo_timers::callback::Timeout; | |
use log::error; | |
use model::model::search::SearchData; | |
use web_sys::wasm_bindgen::JsCast; | |
use web_sys::HtmlInputElement; | |
use yew::prelude::*; | |
use yew_router::prelude::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Serialize, Deserialize)] | |
pub struct SearchData { | |
pub asset_content_data: Vec<AssetContentData>, | |
} | |
#[derive(Serialize, Deserialize, PartialEq, Clone)] | |
pub struct AssetContentData { | |
pub token_id: i32, | |
pub token_address: String, | |
pub name: String, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn get_search_results(pool: &Pool<Postgres>, search: &String) -> Option<SearchData> { | |
return match query_as::<_, AssetContentDb>( | |
"select token_id, token_address, metadata->>'name' as name, metadata->>'image_url' as image_url from asset | |
where ($1~'^\\d+$' and token_id::text like '%' || $1 || '%') or lower(metadata->>'name') like '%' || $1 || '%' | |
order by 1, 3 | |
limit 20", | |
) | |
.bind(search.to_lowercase()) | |
.fetch_all(pool) | |
.await |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::utils::env_utils; | |
use sqlx::postgres::{PgConnectOptions, PgPoolOptions}; | |
use sqlx::{ConnectOptions, Pool, Postgres}; | |
pub async fn create_pool() -> Pool<Postgres> { | |
let options = PgConnectOptions::new() | |
.host(env_utils::as_string("DB_HOST").as_str()) | |
.port(env_utils::as_parsed::<u16>("DB_PORT")) | |
.database(env_utils::as_string("DB_DATABASE").as_str()) | |
.username(env_utils::as_string("DB_USERNAME").as_str()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[actix_web::main] | |
async fn main() -> std::io::Result<()> { | |
let pool = db_handler::create_pool().await; | |
HttpServer::new(move || { | |
App::new() | |
.app_data(Data::new(pool.clone())) | |
.service(search_controller::get_search_results) | |
}) | |
.bind(("127.0.0.1", 8080))? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use actix_web::{get, web, HttpResponse, Responder}; | |
use serde::Deserialize; | |
use sqlx::{Pool, Postgres}; | |
use crate::db::assets_handler; | |
#[derive(Deserialize)] | |
pub struct SearchParams { | |
search: String, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
parameters { | |
choice(name: 'REGION', choices: ['us-east-1']) // add as per your needs | |
string(name: 'AMI_ID', defaultValue: '', description: '', trim: true) | |
} | |
stages { | |
stage('Validate pipeline parameters') { | |
steps { | |
script { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VpcId: <vpc> | |
Subnets: | |
- <subnet> | |
ImageId: AMI_ID | |
InstanceType: i3.2xlarge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
VpcId: | |
Description: VPC id where stack should be deployed | |
Type: AWS::EC2::VPC::Id | |
Subnets: | |
Description: Subnet IDs | |
Type: CommaDelimitedList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE KEYSPACE zoo WITH replication = {'class': 'NetworkTopologyStrategy', '<DATACENTER>' : 3} AND durable_writes = true; | |
USE zoo; | |
CREATE TABLE animals | |
( | |
name text PRIMARY KEY, | |
data map<text, text> | |
); |
NewerOlder