Example #1
0
def main():
    args = parse_args()
    environment = args.get("environment")
    app.config.from_object(util.get_config(environment))

    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
    db.init_app(app)

    with app.app_context():
        create.main()
        insert.main()
Example #2
0
def main():
    args = parse_args()
    environment = args.get("environment")
    config = util.get_config(environment)
    app.config.from_object(util.get_config(environment))
    util.set_logger(config=config, filename=__file__)

    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
    db.init_app(app)
    query = Query(db)

    with app.app_context():
        league_settings = api.get_league_settings(config=config, years=[config.CURRENT_YEAR])
        update(query=query, league_settings=league_settings, year=config.CURRENT_YEAR)
Example #3
0
def main():
    args = parse_args()
    environment = args.get("environment")
    config = util.get_config(environment)
    app.config.from_object(util.get_config(environment))
    util.set_logger(config=config, filename=__file__)

    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
    db.init_app(app)

    with app.app_context():
        logging.info("Dropping tables")
        db.drop_all()
        logging.info("Creating tables")
        db.create_all()
Example #4
0
def main():
    args = parse_args()
    environment = args.get("environment")
    config = util.get_config(environment)
    app.config.from_object(util.get_config(environment))

    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
    db.init_app(app)

    with app.app_context():
        truncate_tables()

        years = api.get_league_years(config)
        league_settings = api.get_league_settings(config, years)
        insert_owners(league_settings)
        insert_records_and_teams(league_settings)
        insert_matchups(league_settings)
        insert_champions()
        insert_sackos()
Example #5
0
def main():
    args = parse_args()
    environment = args.get("environment")
    year = args.get("year")
    week = args.get("week")

    app.config.from_object(util.get_config(environment))
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
    db.init_app(app)
    query = Query(db)

    with app.app_context():
        team_ids = set(query.get_distinct_matchup_team_ids(year)[week])
        team_id_to_team_name = query.get_team_id_to_team_name(year)
        matchups = [
            m for m in query.get_matchups(year)
            if m.matchup_id == week and m.team_id in team_ids
        ]
        for m in matchups:
            team_name = team_id_to_team_name.get(m.team_id)
            opponent_name = team_id_to_team_name.get(m.opponent_team_id)
            team_filename = get_filename(year, week, m.team_id)
            generate_recap_template(team_filename, team_name, opponent_name)
Example #6
0
LOG_FORMAT = "%(asctime)s %(levelname)s %(pathname)s %(lineno)d: %(message)s"

app = Flask(__name__)
app.config.from_object(util.get_config(sys.argv[2]))
app.register_blueprint(awards)
app.register_blueprint(champions)
app.register_blueprint(h2h_records)
app.register_blueprint(matchup_history)
app.register_blueprint(playoffs)
app.register_blueprint(recap)
app.register_blueprint(standings)
app.static_folder = "web/static"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = app.config.get("DB_URI")
db.init_app(app)
query = Query(db)
app.config['QUERY'] = query


@app.template_filter()
def points_format(value):
    return "{:,}".format(value)


@app.template_filter()
def percentage_format(value):
    return "{:.4f}".format(value)


def get_template_path_vars_for_nav(relative_path, pattern, splitter=None):