def indicators_listing(): indicators_rows = database.get_all('indicators') indicators = [] for indicators_row in indicators_rows: indicator = schema.Indicator.from_flat(indicators_row) indicator['id'] = indicators_row.id indicators.append(indicator) indicator_schema = schema.IndicatorsSchema() interlinks_rows = database.get_all('interlinks') interlinks = [ schema.InterlinksSchema.from_flat(interlinks_row) for interlinks_row in interlinks_rows ] trends = {} gmts = {} for indicator in indicators: trends[indicator['id']] = set() gmts[indicator['id']] = set() for interlink in interlinks: if indicator['id'] == interlink['indicator1'].value or \ indicator['id'] == interlink['indicator2'].value or \ indicator['id'] == interlink['indicator3'].value or \ indicator['id'] == interlink['indicator4'].value: trends[indicator['id']].add( interlink['trend'].value_labels[interlink['trend'].value]) gmts[indicator['id']].add( interlink['gmt'].value_labels[interlink['gmt'].value]) return flask.render_template( 'indicators_listing.html', **{ 'indicators': indicators, 'indicator_schema': indicator_schema, 'trends': trends, 'gmts': gmts, })
def post_food(): gia_tien = request.form.get('gia') food_name = request.form.get('ten_mon') photo = request.form.get('img') add_food(food_name,gia_tien) get_all() return render_template('food.html',data=get_all()) #redirect(url_for('get_food'))
def activity_csv(meeting_id): meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id) activity = [schema.ActivitySchema.from_flat(a) for a in database.get_all('activity')] staff = [schema.Staff.from_flat(s) for s in database.get_all('staff')] meetings = [schema.Meeting.from_flat(m) for m in database.get_all('meeting')] valid_subjects = ('edit-participant', 'add-participant', 'edit-participant-photo', 'remove-participant-photo') f = StringIO() writer = sugar.UnicodeWriter(f) # write headers to CSV file headers = [] for i in schema.ActivitySchema().keys(): i = {'subject': 'action', 'what': 'participant', 'what_id': 'participant_id'}.get(i, i) headers.append(i) for row in activity: if row['what_id'].value and row['subject'].value in valid_subjects: headers.append('url') writer.writerow(headers) for row in activity: row_list = [] for k, v in row.items(): val = v.value or '' if k == 'staff_id' and val: val = ['%s %s' % (s['first_name'], s['last_name']) for s in staff if s.id == val][0] if k == 'meeting_id' and val: try: val = [m['info']['acronym'] for m in meetings if m.id == val][0] except IndexError: pass if not isinstance(val, basestring): val = str(val) row_list.append(val) if row['what_id'].value and row['subject'].value in valid_subjects: url = flask.url_for('participant.view', meeting_id=meeting_id, person_id=row['what_id'].value, _external=True) row_list.append(url) writer.writerow(row_list) data = f.getvalue() f.close() return flask.Response(data, mimetype='text/csv')
def activity(meeting_id): page = flask.request.args.get('page', 1) meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id) staff = {s.id: schema.Staff.from_flat(s) for s in database.get_all('staff')} try: staff_id = int(flask.request.args.get('staff_id', 0)) what_id = int(flask.request.args.get('what_id', 0)) seconds = int(flask.request.args.get('seconds', 0)) except ValueError: flask.abort(404) activities = [schema.Activity.from_flat(a, staff=staff) for a in database.find('activity', meeting_id=str(meeting_id))] user_ids = set([a['staff_id'] for a in activities if a['staff_id']]) users = [schema.Staff.from_flat(s) for s in database.get_all('staff') if s.id in user_ids] # filter activities by staff if staff_id: activities = [a for a in activities if a['staff_id'] == staff_id] # filter activities by time span if seconds: timestamp = lambda d: int(time.mktime(d.timetuple())) date_start = int(time.time()) - seconds activities = [a for a in activities if timestamp(a['date']) >= date_start] # filter activities by person if what_id: activities = [a for a in activities if a['what_id'] == what_id] what = activities[0]['what'] if activities else None else: what = None paginator = sugar.Paginator(objects=activities, per_page=50, page=page) activities = paginator.results() return { 'meeting': meeting, 'users': users, 'paginator': paginator, 'activities': activities, 'what_id': what_id, 'what': what, }
def generate_bibliography(self): self.bibtex_output.config(state='normal') self.bibtex_output.delete('1.0', 'end') for source in db.get_all(): self.bibtex_output.insert('end', source.bibtex()) self.bibtex_output.insert('end', '\n') self.bibtex_output.config(state='disabled')
def search(self): author = self.author_input.get() title = self.title_input.get() keyword = self.keyword_input.get() authors = [] titles = [] keywords = [] if author: authors = db.query_author(author) if title: titles = db.query_title(title) if keyword: keywords = db.query_keyword( [x.strip() for x in keyword.split(',')]) if not author and not title and not keyword: authors = db.get_all() self.result_list.delete(0, 'end') for result in sorted(set().union(authors, titles, keywords), key=lambda x: x.author_surnames()): item = result.list_entry() self.results[item] = result self.result_list.insert('end', item)
def home(): staff = database.get_all("staff") staff = [schema.Staff.from_flat(s) for s in staff if not s.get("other", False)] return { "staff": staff }
def timelines_listing(): timelines_rows = database.get_all('timelines') timelines = [ schema.Timeline.from_flat(timelines_row) for timelines_row in timelines_rows ] return flask.render_template('timelines_listing.html', **{'timelines': timelines})
def sources_listing(): sources_rows = database.get_all('sources') sources = [ schema.Source.from_flat(sources_row) for sources_row in sources_rows ] return flask.render_template('sources_listing.html', **{ 'sources': sources, })
def get_tasks_json(): all_tasks = [ {"id": id, "created": timestamp2iso(created), "finished": timestamp2iso(finished), "result": result or ''} for id, created, finished, result in database.get_all()] return {"all_tasks": all_tasks}
def update_participants_region(): session = database.get_session() countries = [schema.Country.from_flat(c) for c in database.get_all("country")] countries = {c["iso"].value: c["region"].value for c in countries} for p in database.get_all("person"): try: region = int(p['representing_region']) if region == 0: region = None except ValueError: region = None if not region and p["representing_country"]: p["representing_region"] = countries[p["representing_country"]] session.save(p) session.commit()
def export(): datadict = {} for table in TABLES: rows = {} for row in database.get_all(table): rows[row.id] = row datadict[table] = rows return flask.json.dumps(datadict)
def documents(meeting_id): meeting = sugar.get_object_or_404(models.Meeting, id=meeting_id) documents = database.get_all('document') documents = [schema.Document.from_flat(d) for d in documents if int(d['meeting_id']) == meeting.id] return { 'meeting': meeting, 'documents': documents, }
def export_training_set(): os.unlink('data/training.csv') csv_columns = ['wins','elo','score','score_against','momentum','vs','ts','outcome'] games = db.get_all('games','id','desc') with open('data/training.csv', 'a', newline='') as c: full_write = csv.DictWriter(c, fieldnames=csv_columns) for g in games: del g['Id'] full_write.writerow(g)
def interlinks_listing(): interlinks_rows = database.get_all('interlinks') interlinks = [ schema.Interlink.from_flat(interlinks_row) for interlinks_row in interlinks_rows ] return flask.render_template('interlinks_listing.html', **{ 'interlinks': interlinks, })
def find_gap(): book = dtb.get_all() for i in range(0, len(book) - 1): if book[i][0] != book[i + 1][0] - 1: print(book[i]) print(book[i + 1]) #if book[i][-3] == None: # print (book[i][0]) print(len(book))
def steep_categories_listing(): steep_categories_rows = database.get_all('steep_categories') steep_categories = [ schema.GeographicalCoverage.from_flat(steep_categories_row) for steep_categories_row in steep_categories_rows ] return flask.render_template('steep_categories_listing.html', **{ 'steep_categories': steep_categories, })
def geo_coverages_listing(): geo_coverages_rows = database.get_all('geo_coverages') geo_coverages = [ schema.GeographicalCoverage.from_flat(geo_coverages_row) for geo_coverages_row in geo_coverages_rows ] return flask.render_template('geo_coverages_listing.html', **{ 'geo_coverages': geo_coverages, })
def thematic_categories_listing(): thematic_categories_rows = database.get_all('thematic_categories') thematic_categories = [ schema.ThematicCategory.from_flat(thematic_categories_row) for thematic_categories_row in thematic_categories_rows ] return flask.render_template( 'thematic_categories_listing.html', **{ 'thematic_categories': thematic_categories, })
def ban_users(): all_users = database.get_all() banned = [x for x in all_users if random.randint(1, 100) % 2 == 0] # list banned will contain everyone that needs to get banned not_banned = [x for x in all_users if not x in banned] for user in banned: subreddit.flair.set(user,'perished') #Subreddit.banned.add(user, ban_reason='The universe needs balance') for user in not_banned: subreddit.flair.set(user,'survived')
def get(self): #print(self.request) id = self.get_argument('id', default=None) if id == None: result = database.get_all() for r in result: self.write(dict(r.id, r.name, r.quantity)) else: r = database.get(int(id)) self.write(dict(r.id, r.name, r.quantity))
def is_referenced(table, row_id): found = [] for r_table, r_values in REFERENCES.items(): if table in r_values.keys(): rows = database.get_all(r_table) for row in rows: for field in r_values[table]: if row[field] == str(row_id): found.append('%s/%s' % (r_table, row.id)) return found
def update_activity_what_id(): session = database.get_session() activity = [a for a in database.get_all("activity")] persons = [schema.Person.from_flat(p) for p in database.get_all("person")] persons = {p.name: p.id for p in persons} def replace_title(name): for i in ("Mr", "Ms", "M", "Mme.", "Sra.", "Sr."): name = name.replace(i, "") return name.strip() for a in activity: p = persons.get(a["what"], None) or persons.get(replace_title(a["what"]), None) if p: a["what_id"] = str(p) session.save(a) session.commit()
def update_participants_none_to_empty_values(): session = database.get_session() for p in database.get_all("person"): for k,v in p.items(): #convert None to empty strings if v == u'None': p[k] = u'' session.save(p) session.commit()
def kstats(update, context): if update.message.from_user.id not in sudoList: reply(update.effective_message, s.NOT_SUDO) return ulist = [] db = sql.get_all() for i in db: if i[1] not in ulist: ulist.append(i[1]) ucount = len(ulist) pcount = len(db) update.effective_message.reply_text(s.STATS.format(ucount, pcount))
async def on_ready(self): print("Timer start") guild = self.bot.get_guild(main_guild) while True: for user in get_all(Muted): if datetime.now() >= user.timewarn: print(type(user)) member = guild.get_member(user.id) role = guild.get_role(mute_role) delete_mute(user) await member.send("С тебя сняли мут.") await member.remove_roles(role) await sleep(30)
def update_staff_members_passwords(): session = database.get_session() app = flask.current_app staff_members = [i for i in database.get_all("staff")] for account in app.config["ACCOUNTS"]: staff_member = [i for i in staff_members if i.get("email") == account[0]] if staff_member: staff_member = staff_member[0] staff_member["password"] = sugar.make_hash(account[1]) session.save(staff_member) session.commit()
def make_training_set(): print("\n\nCreating Training Set") db.clear_table('games') games = db.get_all('processed', 'id') bar = progressbar.ProgressBar(max_value=len(games)) cnt = 0 for g in games: bar.update(cnt) cnt += 1 vs_games = g['a_vs_record'] + g['b_vs_record'] match = { 'wins': stat_avg_diff(g['a_win'], g['a_games'], g['b_win'], g['b_games']), 'map_score': stat_avg_diff(g['a_map_win'], g['a_map_played'], g['b_map_win'], g['b_map_played']), 'elo': round(g['a_elo'] - g['b_elo'], 2), 'vs': stat_avg_diff(g['a_vs_record'], vs_games, g['b_vs_record'], vs_games), 'score': stat_avg_diff(g['a_score'], g['a_games'], g['b_score'], g['b_games']), 'momentum': g['a_momentum'] - g['b_momentum'], 'kd': stat_avg_diff(g['a_kd'], g['a_games'], g['b_kd'], g['b_games']), 'kast': stat_avg_diff(g['a_kast'], g['a_games'], g['b_kast'], g['b_games']), 'rating': stat_avg_diff(g['a_rating'], g['a_games'], g['b_rating'], g['b_games']), 'adr': stat_avg_diff(g['a_adr'], g['a_games'], g['b_adr'], g['b_games']), 'ts': g['a_trueskill'], 'outcome': g['outcome'], 'date': g['date'] } db.insert_game('games', match)
def setup_teams(): teams = {} vs_teams = {} maps = { 'cbl': 0, 'cch': 0, 'd2': 0, 'inf': 0, 'mrg': 0, 'nuke': 0, 'ovp': 0, 'tcn': 0, 'trn': 0, 'season': 0, 'vtg': 0 } games = db.get_all('teams', 'id') for g in games: teams[g['team']] = MAX_VS_MATCHES / 2 vs_teams[g['team']] = { 'teams': 0, 'stats': 0, 'map_wins': 0, 'map_games': 0 } for t in teams: vs_teams[t]['teams'] = teams vs_teams[t]['stats'] = { 'elo': 1000, 'games': 0, 'wins': 0, 'score': 0, 'momentum': 0, 'adr': 0, 'rating': 0, 'kills': 0, 'deaths': 0, 'kast': 0, 'ts': trueskill.Rating() } vs_teams[t]['map_wins'] = maps vs_teams[t]['map_games'] = maps return vs_teams
def updat_resolution_order(): session = database.get_session() conf_regex = re.compile('(\d+)\.(\d+)') for resolution in database.get_all('resolution'): if conf_regex.search(resolution['number']): first_number = conf_regex.search(resolution['number']).group(1) second_number = conf_regex.search(resolution['number']).group(2) if len(first_number) == 1: first_number = '0' + first_number if len(second_number) == 1: second_number = '0' + second_number resolution['order'] = first_number + '-' + second_number else: print 'error', resolution['number'] session.save(resolution) session.commit()
def pay(): ''' Payment page, the client comes to this page after clicking "Pay" on the merchant page ''' # request.args looks ugly and takes too much space... args = request.args keys = args.keys() required_keys = ['checkout_token'] # Checking for required arguments if not args or not check_keys(required_keys, keys): return redirect(url_for('index', error = "invalid_checkout")) # Getting row from database of the checkout checkout = db.get('CHECKOUT', 'id', args['checkout_token']); # Checking if checkout is valid if not checkout: return redirect(url_for('index', error = "invalid_checkout")) # Get items and merchant items = db.get_all('ITEM', 'checkout', args['checkout_token']); merchant = db.get('MERCHANT', 'id', checkout['merchant']) # Checking if checkout was already paid if checkout['status'] != "CREATED": return redirect(checkout['return_url'] + "?checkout_token=" + args['checkout_token'] ) # Checking if user is already logged in login_form = False if 'user_id' in session and db.exists('CLIENT', 'id', session['user_id']) else True # Checking if there is error message to be shown error = False if not request.args.get('error') else request.args.get('error') return render_template('pay.html', amount = "{:.2f}".format(checkout['amount']), items = items, currency = checkout['currency'] if checkout['currency'] else 'EUR', login_form = login_form, merchant_logo = merchant['logo'], merchant_name = merchant['name'], error = error_message(error) ), 200
from helpers import number_format # ToDo move to config telegram_output_file = "telegram_report.csv" delimiter = ',' headers = view_data + ('Telegram Name', 'Last seen', 'Telegram Profile') with open(telegram_output_file, 'w', encoding='cp1251') as csv_file: writer = csv.DictWriter(csv_file, fieldnames=headers, delimiter=delimiter, lineterminator='\n') writer.writeheader() for _line in get_all(): for p_number in _line[0].split('\n'): profile_tmp = list(_line) # Phone number profile_tmp[0] = number_format(p_number) # Addition telegram name, seen telegram_user = get_user_from_telegram(number_format(p_number)) if telegram_user: [profile_tmp.append(item) for item in telegram_user[0][2:-1]] # Processing of profile if telegram_user[0][-1]: profile_tmp.append(telegram_user[0][4].replace( 'Username', '').replace('About', '').replace('\n', ' '))
def process_totals(): db.clear_table('processed') teams = setup_teams() games = db.get_all('raw', 'id', 'DESC') match = {} ts = trueskill.TrueSkill(draw_probability=0) add_list = [] bar = progressbar.ProgressBar(max_value=len(games)) print("\nProcessing Team Totals:") cnt = 0 for g in games: try: bar.update(cnt) cnt += 1 if g['a_score'] != g['b_score']: if teams[g['team_a']]['stats']['games'] > MIN_GAMES and teams[ g['team_b']]['stats']['games'] > MIN_GAMES: match = { 'team_a': g['team_a'], 'team_b': g['team_b'], 'a_score': teams[g['team_a']]['stats']['score'], 'b_score': teams[g['team_b']]['stats']['score'], 'a_elo': teams[g['team_a']]['stats']['elo'], 'b_elo': teams[g['team_b']]['stats']['elo'], 'a_games': teams[g['team_a']]['stats']['games'], 'b_games': teams[g['team_b']]['stats']['games'], 'a_win': teams[g['team_a']]['stats']['wins'], 'b_win': teams[g['team_b']]['stats']['wins'], 'a_map_win': teams[g['team_a']]['map_wins'][g['map']], 'b_map_win': teams[g['team_b']]['map_wins'][g['map']], 'a_map_played': teams[g['team_a']]['map_games'][g['map']], 'b_map_played': teams[g['team_b']]['map_games'][g['map']], 'a_vs_record': teams[g['team_a']]['teams'][g['team_b']], 'b_vs_record': teams[g['team_b']]['teams'][g['team_a']], 'a_momentum': teams[g['team_a']]['stats']['momentum'], 'b_momentum': teams[g['team_b']]['stats']['momentum'], 'a_adr': teams[g['team_a']]['stats']['adr'], 'b_adr': teams[g['team_b']]['stats']['adr'], 'a_kast': teams[g['team_a']]['stats']['kast'], 'b_kast': teams[g['team_b']]['stats']['kast'], 'a_kd': round( teams[g['team_a']]['stats']['kills'] / teams[g['team_a']]['stats']['deaths'], 4), 'b_kd': round( teams[g['team_b']]['stats']['kills'] / teams[g['team_b']]['stats']['deaths'], 4), 'a_rating': teams[g['team_a']]['stats']['rating'], 'b_rating': teams[g['team_b']]['stats']['rating'], 'a_trueskill': win_probability(teams[g['team_a']]['stats']['ts'], teams[g['team_b']]['stats']['ts']), 'b_trueskill': win_probability(teams[g['team_b']]['stats']['ts'], teams[g['team_a']]['stats']['ts']), 'outcome': g['outcome'], 'date': g['date'] } db.insert_game('processed', match) teams[g['team_a']]['stats']['games'] += 1 teams[g['team_b']]['stats']['games'] += 1 teams[g['team_a']]['stats']['score'] += g['a_score'] teams[g['team_b']]['stats']['score'] += g['b_score'] teams[g['team_a']]['map_games'][g['map']] += 1 teams[g['team_b']]['map_games'][g['map']] += 1 teams[g['team_a']]['stats']['adr'] += g['a_adr'] teams[g['team_b']]['stats']['adr'] += g['b_adr'] teams[g['team_a']]['stats']['rating'] += g['a_rating'] teams[g['team_b']]['stats']['rating'] += g['b_rating'] teams[g['team_a']]['stats']['kills'] += g['a_kills'] teams[g['team_b']]['stats']['kills'] += g['b_kills'] teams[g['team_a']]['stats']['deaths'] += g['a_deaths'] teams[g['team_b']]['stats']['deaths'] += g['b_deaths'] teams[g['team_a']]['stats']['kast'] += g['a_kast'] teams[g['team_b']]['stats']['kast'] += g['b_kast'] if g['outcome'] == 1: winner, loser = 'team_a', 'team_b' win_score, lose_score = g['a_score'], g['b_score'] else: winner, loser = 'team_b', 'team_a' win_score, lose_score = g['b_score'], g['a_score'] teams[g[winner]]['stats']['ts'], teams[ g[loser]]['stats']['ts'] = trueskill.rate_1vs1( teams[g[winner]]['stats']['ts'], teams[g[loser]]['stats']['ts']) teams[g[winner]]['stats']['elo'], teams[ g[loser]]['stats']['elo'] = elo( teams[g[winner]]['stats']['elo'], teams[g[loser]]['stats']['elo']) teams[g[winner]]['stats']['wins'] += ( 1 + math.log(win_score - lose_score)) teams[g[loser]]['teams'][g[winner]] -= 1 if teams[g[loser]]['teams'][g[winner]] < 0: teams[g[loser]]['teams'][g[winner]] = 0 if teams[g[winner]]['teams'][g[loser]] > MAX_VS_MATCHES: teams[g[winner]]['teams'][g[loser]] = MAX_VS_MATCHES teams[g[winner]]['teams'][g['team_a']] += 1 teams[g[winner]]['map_wins'][g['map']] += ( 1 + math.log(win_score - lose_score)) teams[g[winner]]['stats']['rating'] += WIN_RATING_SCORE teams[g[loser]]['stats']['momentum'] = round( teams[g[loser]]['stats']['momentum'] / LOSS_MOMENTUM, 4) teams[g[winner]]['stats']['momentum'] += 1 except Exception as e: print("### Error:", e) pass return teams
def get_clients(): clients = db.get_all() return clients
def get(self): all_records=database.get_all() print(all_records) self.render('templates/list.html', all_records=all_records, title='Staff List')
def getData(): data = db.get_all() print data return jsonify({ "data" : data })
import csv from database import view_data, get_all path_output_file = "report.csv" with open(path_output_file, 'w') as csv_file: writer = csv.DictWriter(csv_file, fieldnames=view_data, delimiter=';', lineterminator='\n') writer.writeheader() lines = get_all() for _line in lines: writer.writerow(dict(zip(view_data, _line))) # For example # import subprocess # cmd = 'start excel {}'.format(path_output_file) # subprocess.call(cmd, shell=True)
def process_totals(): db.clear_table('processed') for season in range(1990,2019): print(season) teams = setup_teams() games = db.get_all('raw','id','DESC',season) match = {} ts = trueskill.TrueSkill(draw_probability=0) for g in games: try: if g['a_score'] != g['b_score']: if teams[g['team_a']]['stats']['games'] > MIN_GAMES_PLAYED and teams[g['team_b']]['stats']['games'] > MIN_GAMES_PLAYED: match = { 'team_a': g['team_a'], 'team_b': g['team_b'], 'a_score': teams[g['team_a']]['stats']['score'], 'b_score': teams[g['team_b']]['stats']['score'], 'a_score_against': teams[g['team_a']]['stats']['score_against'], 'b_score_against': teams[g['team_b']]['stats']['score_against'], 'a_elo': teams[g['team_a']]['stats']['elo']+HOME_ADV, 'b_elo': teams[g['team_b']]['stats']['elo'], 'a_games': teams[g['team_a']]['stats']['games'], 'b_games': teams[g['team_b']]['stats']['games'], 'a_win': teams[g['team_a']]['stats']['wins'], 'b_win': teams[g['team_b']]['stats']['wins'], 'a_vs_record': teams[g['team_a']]['teams'][g['team_b']], 'b_vs_record': teams[g['team_b']]['teams'][g['team_a']], 'a_momentum': teams[g['team_a']]['stats']['momentum'], 'b_momentum': teams[g['team_b']]['stats']['momentum'], 'a_trueskill': win_probability(teams[g['team_a']]['stats']['ts'], teams[g['team_b']]['stats']['ts']), 'b_trueskill': win_probability(teams[g['team_b']]['stats']['ts'], teams[g['team_a']]['stats']['ts']), 'outcome': g['outcome'], 'season': season, } db.insert_game('processed', match) teams[g['team_a']]['stats']['games'] += 1 teams[g['team_b']]['stats']['games'] += 1 teams[g['team_a']]['stats']['score'] += g['a_score'] teams[g['team_b']]['stats']['score'] += g['b_score'] teams[g['team_a']]['stats']['score_against'] += g['b_score'] teams[g['team_b']]['stats']['score_against'] += g['a_score'] if g['outcome'] == 1: winner = 'team_a' loser = 'team_b' win_score = g['a_score'] lose_score = g['b_score'] else: winner = 'team_b' loser = 'team_a' win_score = g['b_score'] lose_score = g['a_score'] teams[g[winner]]['stats']['ts'], teams[g[loser]]['stats']['ts'] = trueskill.rate_1vs1(teams[g[winner]]['stats']['ts'],teams[g[loser]]['stats']['ts']) teams[g[winner]]['stats']['elo'], teams[g[loser]]['stats']['elo'] = elo(teams[g[winner]]['stats']['elo'], teams[g[loser]]['stats']['elo']) teams[g[winner]]['stats']['wins'] +=(win_score-lose_score) teams[g[winner]]['teams'][g[loser]] += 1 teams[g[loser]]['stats']['momentum'] = round(teams[g[loser]]['stats']['momentum']/MOMENTUM_DEGRADE,4) teams[g[winner]]['stats']['momentum'] += (1+ math.log(win_score-lose_score)) except Exception as e: print(g) print(e) return teams
def gmts_listing(): gmts_rows = database.get_all('gmts') gmts = [schema.GMT.from_flat(gmts_row) for gmts_row in gmts_rows] return flask.render_template('gmts_listing.html', **{ 'gmts': gmts, })
def trends_listing(): trends_rows = database.get_all('trends') trends = [schema.Trend.from_flat(trends_row) for trends_row in trends_rows] return flask.render_template('trends_listing.html', **{ 'trends': trends, })