Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free tier #622

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ auto-reload.sh
nginx-container/front-end-dist/
*.validator.ts
secrets.json
scripts/**/node_modules/
.serverless/

# Created by https://www.gitignore.io/api/intellij
# Edit at https://www.gitignore.io/?templates=intellij
Expand Down
1 change: 1 addition & 0 deletions .idea/modules.xml

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Add is_frozen column to AWS accounts table
Revision ID: 2ea8fd0edbea
Revises: 820815b85cf7
Create Date: 2020-02-20 12:31:08.669968
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2ea8fd0edbea'
down_revision = '820815b85cf7'
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"aws_accounts",
sa.Column(
"is_frozen",
sa.Boolean,
default=False
)
)
op.execute("UPDATE aws_accounts SET is_frozen = false")


def downgrade():
op.drop_column(
"aws_accounts",
"is_frozen"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Add tier column to users table
Revision ID: 820815b85cf7
Revises: b1c3d08b9adc
Create Date: 2020-02-19 11:05:17.089495
"""
from alembic import op

import sqlalchemy as sa

from models.users import RefineryUserTier

# revision identifiers, used by Alembic.
revision = '820815b85cf7'
down_revision = 'b1c3d08b9adc'
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
'_dummy',
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('status', sa.Enum(RefineryUserTier))
)
op.drop_table('_dummy')

op.add_column(
'users',
sa.Column(
'tier',
sa.Enum(RefineryUserTier),
nullable=True,
# Set default to paid since all users before free-tier
# will indeed be paid users
server_default="PAID"
)
)

# Now modify the column to not allow null
op.alter_column(
'users',
'tier',
nullable=False
)

def downgrade():
op.drop_column('users', 'tier')
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Add lambda execution monthly report table to the database

Revision ID: ea7fb2d93b78
Revises: 2ea8fd0edbea
Create Date: 2020-07-16 14:55:59.708033

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ea7fb2d93b78'
down_revision = '2ea8fd0edbea'
branch_labels = None
depends_on = None


def upgrade():
op.create_table(
'lambda_execution_monthly_reports',
sa.Column('id', sa.CHAR(36), primary_key=True),
sa.Column(
'account_id',
sa.Text(),
sa.ForeignKey(
"aws_accounts.account_id"
),
index=True,
),
sa.Column(
"gb_seconds_used",
sa.Float()
),
sa.Column(
"total_executions",
sa.Integer()
),
sa.Column(
"timestamp",
sa.Integer(),
index=True
)
)


def downgrade():
op.drop_table('lambda_execution_monthly_reports')
10 changes: 9 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import tornado.httpserver

from controller.auth import *
from controller.auth.downgrade_account_tier import DowngradeAccountTier
from controller.auth.github import *
from controller.auth.upgrade_account_tier import UpgradeAccountTier
from controller.aws import *
from controller.billing import *
from controller.deployments import *
Expand All @@ -12,11 +14,13 @@
from controller.health import *
from controller.internal import *
from controller.lambdas import *
from controller.lambdas.realtime_lambda_billing_watchdog import RealtimeLambdaBillingWatchdog
from controller.logs import *
from controller.projects import *
from controller.projects.controllers_short_links import GetProjectShortlink, CreateProjectShortlink
from controller.saved_blocks import *
from controller.services import *
from controller.services.rescan_free_tier_accounts import RescanFreeTierAccounts
from controller.websockets import *

from controller.websockets import LambdaConnectBackServer
Expand Down Expand Up @@ -75,7 +79,7 @@ def make_app(self, object_graph):
(r"/api/v1/auth/register", NewRegistration),
(r"/api/v1/auth/login", Authenticate),
(r"/api/v1/auth/logout", Logout),
( r"/api/v1/auth/github", AuthenticateWithGithub, "auth_github" ),
(r"/api/v1/auth/github", AuthenticateWithGithub, "auth_github"),

(r"/api/v1/logs/executions/get-logs", GetProjectExecutionLogObjects),
(r"/api/v1/logs/executions/get-contents", GetProjectExecutionLogsPage),
Expand Down Expand Up @@ -118,6 +122,7 @@ def make_app(self, object_graph):
(r"/api/v1/billing/creditcards/list", ListCreditCards),
(r"/api/v1/billing/creditcards/delete", DeleteCreditCard),
(r"/api/v1/billing/creditcards/make_primary", MakeCreditCardPrimary),
(r"/api/v1/billing/tier/upgrade", UpgradeAccountTier),
# Temporarily disabled since it doesn't cache the CostExplorer results
#( r"/api/v1/billing/forecast_for_date_range", GetBillingDateRangeForecast ),

Expand Down Expand Up @@ -150,6 +155,9 @@ def make_app(self, object_graph):
(r"/services/v1/clear_stripe_invoice_drafts", ClearStripeInvoiceDrafts),
(r"/services/v1/mark_account_needs_closing", MarkAccountNeedsClosing),
(r"/services/v1/remove_needs_closing_accounts", RemoveNeedsClosingAccounts),
(r"/services/v1/store_lambda_execution_details", RealtimeLambdaBillingWatchdog),
(r"/services/v1/rescan_free_tier_accounts", RescanFreeTierAccounts),
(r"/services/v1/downgrade_account_tier", DowngradeAccountTier),
]

# Sets up routes
Expand Down
Loading