def preload(cls, data: Data, config: Dict[str, Any]) -> None: cache = Cache(app, config={ 'CACHE_TYPE': 'filesystem', 'CACHE_DIR': config['cache_dir'], }) frontend = ReflecBeatFrontend(data, config, cache) frontend.get_all_songs(force_db_load=True)
def viewscores(userid: UserID) -> Response: frontend = ReflecBeatFrontend(g.data, g.config, g.cache) info = frontend.get_latest_player_info([userid]).get(userid) if info is None: abort(404) scores = frontend.get_scores(userid, limit=100) if len(scores) > 10: scores = frontend.round_to_ten(scores) return render_react( '{}\'s Reflec Beat Scores'.format(info['name']), 'reflec/scores.react.js', { 'attempts': scores, 'songs': frontend.get_all_songs(), 'players': {}, 'shownames': False, 'shownewrecords': True, }, { 'refresh': url_for('reflec_pages.listscores', userid=userid), 'player': url_for('reflec_pages.viewplayer', userid=-1), 'individual_score': url_for('reflec_pages.viewtopscores', musicid=-1), }, )
def viewrecords(userid: UserID) -> Response: frontend = ReflecBeatFrontend(g.data, g.config, g.cache) info = frontend.get_latest_player_info([userid]).get(userid) if info is None: abort(404) versions = {version: name for (game, version, name) in frontend.all_games()} return render_react( '{}\'s Reflec Beat Records'.format(info['name']), 'reflec/records.react.js', { 'records': frontend.get_records(userid), 'songs': frontend.get_all_songs(), 'players': {}, 'versions': versions, 'shownames': False, 'showpersonalsort': True, 'filterempty': True, }, { 'refresh': url_for('reflec_pages.listrecords', userid=userid), 'player': url_for('reflec_pages.viewplayer', userid=-1), 'individual_score': url_for('reflec_pages.viewtopscores', musicid=-1), }, )
def viewnetworkscores() -> Response: # Only load the last 100 results for the initial fetch, so we can render faster frontend = ReflecBeatFrontend(g.data, g.config, g.cache) network_scores = frontend.get_network_scores(limit=100) if len(network_scores['attempts']) > 10: network_scores['attempts'] = frontend.round_to_ten(network_scores['attempts']) return render_react( 'Global Reflec Beat Scores', 'reflec/scores.react.js', { 'attempts': network_scores['attempts'], 'songs': frontend.get_all_songs(), 'players': network_scores['players'], 'shownames': True, 'shownewrecords': False, }, { 'refresh': url_for('reflec_pages.listnetworkscores'), 'player': url_for('reflec_pages.viewplayer', userid=-1), 'individual_score': url_for('reflec_pages.viewtopscores', musicid=-1), }, )
def viewnetworkrecords() -> Response: frontend = ReflecBeatFrontend(g.data, g.config, g.cache) network_records = frontend.get_network_records() versions = {version: name for (game, version, name) in frontend.all_games()} return render_react( 'Global Reflec Beat Records', 'reflec/records.react.js', { 'records': network_records['records'], 'songs': frontend.get_all_songs(), 'players': network_records['players'], 'versions': versions, 'shownames': True, 'showpersonalsort': False, 'filterempty': False, }, { 'refresh': url_for('reflec_pages.listnetworkrecords'), 'player': url_for('reflec_pages.viewplayer', userid=-1), 'individual_score': url_for('reflec_pages.viewtopscores', musicid=-1), }, )