-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2947 from centerofci/0.1.2
Release 0.1.2
- Loading branch information
Showing
241 changed files
with
7,544 additions
and
3,319 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Stores GitHub repo stats daily, to overcome the 14-day limitation of GitHub's built-in traffic statistics. | ||
name: github-repo-stats | ||
|
||
on: | ||
schedule: | ||
# Run this once per day, towards the end of the day for keeping the most | ||
# recent data point most meaningful (hours are interpreted in UTC). | ||
- cron: "0 23 * * *" | ||
workflow_dispatch: # Allow for running this manually. | ||
|
||
jobs: | ||
j1: | ||
name: github-repo-stats | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: run-ghrs | ||
# Use latest release. | ||
uses: jgehrcke/github-repo-stats@RELEASE | ||
with: | ||
ghtoken: ${{secrets.MATHESAR_ORG_GITHUB_TOKEN}} |
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
from alembic.migration import MigrationContext | ||
from alembic.operations import Operations | ||
|
||
from db.columns.operations.select import get_column_name_from_attnum | ||
from db.tables.operations.select import reflect_table_from_oid | ||
from db.metadata import get_empty_metadata | ||
"""The function in this module wraps SQL functions that drop columns.""" | ||
from db import connection as db_conn | ||
|
||
|
||
def drop_column(table_oid, column_attnum, engine): | ||
# TODO reuse metadata | ||
metadata = get_empty_metadata() | ||
table = reflect_table_from_oid(table_oid, engine, metadata=metadata) | ||
column_name = get_column_name_from_attnum(table_oid, column_attnum, engine, metadata=metadata) | ||
column = table.columns[column_name] | ||
with engine.begin() as conn: | ||
ctx = MigrationContext.configure(conn) | ||
op = Operations(ctx) | ||
op.drop_column(table.name, column.name, schema=table.schema) | ||
""" | ||
Drop the given columns from the given table. | ||
Args: | ||
table_oid: OID of the table whose columns we'll drop. | ||
column_attnum: The attnums of the columns to drop. | ||
engine: SQLAlchemy engine object for connecting. | ||
Returns: | ||
Returns a string giving the command that was run. | ||
""" | ||
return db_conn.execute_msar_func_with_engine( | ||
engine, 'drop_columns', table_oid, column_attnum | ||
).fetchone()[0] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from sqlalchemy import text | ||
import psycopg | ||
|
||
|
||
def execute_msar_func_with_engine(engine, func_name, *args): | ||
""" | ||
Execute an msar function using an SQLAlchemy engine. | ||
This is temporary scaffolding. | ||
Args: | ||
engine: an SQLAlchemy engine for connecting to a DB | ||
func_name: The unqualified msar function name (danger; not sanitized) | ||
*args: The list of parameters to pass | ||
""" | ||
conn_str = str(engine.url) | ||
with psycopg.connect(conn_str) as conn: | ||
# Returns a cursor | ||
return conn.execute( | ||
f"SELECT msar.{func_name}({','.join(['%s']*len(args))})", | ||
args | ||
) | ||
|
||
|
||
def execute_msar_func_with_psycopg2_conn(conn, func_name, *args): | ||
""" | ||
Execute an msar function using an SQLAlchemy engine. | ||
This is *extremely* temporary scaffolding. | ||
Args: | ||
conn: a psycopg2 connection (from an SQLAlchemy engine) | ||
func_name: The unqualified msar function name (danger; not sanitized) | ||
*args: The list of parameters to pass | ||
""" | ||
args_str = ", ".join([str(arg) for arg in args]) | ||
args_str = f"{args_str}" | ||
stmt = text(f"SELECT msar.{func_name}({args_str})") | ||
# Returns a cursor | ||
return conn.execute(stmt) | ||
|
||
|
||
def load_file_with_engine(engine, file_handle): | ||
"""Run an SQL script from a file, using psycopg.""" | ||
conn_str = str(engine.url) | ||
with psycopg.connect(conn_str) as conn: | ||
conn.execute(file_handle.read()) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
from alembic.migration import MigrationContext | ||
from alembic.operations import Operations | ||
from db.connection import execute_msar_func_with_engine | ||
|
||
|
||
def drop_constraint(table_name, schema, engine, constraint_name): | ||
with engine.begin() as conn: | ||
ctx = MigrationContext.configure(conn) | ||
op = Operations(ctx) | ||
op.drop_constraint(constraint_name, table_name, schema=schema) | ||
def drop_constraint(table_name, schema_name, engine, constraint_name): | ||
""" | ||
Drop a constraint. | ||
Args: | ||
table_name: The name of the table that has the constraint to be dropped. | ||
schema_name: The name of the schema where the table with constraint to be dropped resides. | ||
engine: SQLAlchemy engine object for connecting. | ||
constraint_name: The name of constraint to be dropped. | ||
Returns: | ||
Returns a string giving the command that was run. | ||
""" | ||
return execute_msar_func_with_engine( | ||
engine, 'drop_constraint', schema_name, table_name, constraint_name | ||
).fetchone()[0] |
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
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
Oops, something went wrong.