web3-proxy/migration/src/m20230119_204135_better_fre...
Bryan Stitt f0b6465069
streaming responses 2 (#219)
* streaming responses compile, still small TODOs & cleanup

* refactor to allow short curcuits on uncacheable requests (#220)

* refactor to allow short curcuits on uncacheable requests

* handle error inside an Arc from moka

* arc instead of box

* lint

* more lint

* add bonus rate limits and keep all semaphores after rate limits (#221)

* add bonus rate limits and keep all semaphores after rate limits

* remove stale todos

* better function names

* cargo upgrade and update

* make some panics warn. more todo

* pass request_metadata through so streaming responses include their final size

* remove stale TODO

* remove more stale todos

* add file i missed

* make to_json_string work well enough

* check config for free_subscriptions

---------

Co-authored-by: Rory Neithinger <rory@llamanodes.com>
2023-09-26 18:18:06 -07:00

40 lines
1.1 KiB
Rust

//! Increase requests per minute for the free tier to be better than our public tier (which has 3900/min)
use sea_orm_migration::{prelude::*, sea_orm::ConnectionTrait};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db_conn = manager.get_connection();
let db_backend = manager.get_database_backend();
let update_free = Query::update()
.table(UserTier::Table)
.value(UserTier::MaxRequestsPerPeriod, 6000)
.and_where(Expr::col(UserTier::Title).eq("Free"))
.limit(1)
.to_owned();
let x = db_backend.build(&update_free);
let rows_affected = db_conn.execute(x).await?.rows_affected();
assert_eq!(rows_affected, 1, "unable to update free tier");
Ok(())
}
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
unimplemented!();
}
}
#[derive(Iden)]
enum UserTier {
Table,
Title,
MaxRequestsPerPeriod,
}