def get(self): path = 'startups_latest.html' q = Company.all() logging.info(q.count()) companies = [self.make_dict(company) for company in q] companies.insert(0, {'image': '/assets/img/new_startup.png', 'name': 'Your Startup', 'url': '/startups/registration/queue'}) sorted_company_rows = [companies[i: i+3] for i in range(0, len(companies), 3)] template_values = {'startups' : sorted_company_rows, 'nav_color':'dark-nav'} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): path = 'startups_search_results.html' project_id = long(self['project_id']) project = Project.get_by_id(project_id) skills = project.skills q = Company.all() sorted_companies = {} for c in q.fetch(50): expertise_dict = convert_string_list_to_dict(c.expertise_avg) score = 0.0 matched_skills = 0.0 fit = 0.0 id = c.key().id() sorted_companies[id] = {} sorted_companies[id]['name'] = c.name sorted_companies[id]['influence'] = c.influence_avg sorted_companies[id]['skills'] = [] if skills: for skill in skills: skill = str(skill) if skill in expertise_dict: skill_dict = { 'name': skill, 'value': float(expertise_dict[skill]) } score += float(expertise_dict[skill]) matched_skills += 1 else: skill_dict = {'name': skill, 'value': 0.0} sorted_companies[id]['skills'].append(skill_dict) score = float(score / len(skills)) fit = float(matched_skills / len(skills)) if matched_skills > 0.0 else 0.0 sorted_companies[id]['combined'] = score sorted_companies[id]['fit'] = fit donuts = (len(skills) if skills else 0) + 3 sorted_companies = sorted(sorted_companies.iteritems(), key=lambda (k, v): v['combined'], reverse=True) donut_size = 80 - (5 * donuts) score_font_size = 40 - (2.25 * donuts) tooltip_font_size = 14 - donuts template_values = { 'startups': sorted_companies, 'skills': skills, 'donut_size': donut_size, 'score_font_size': score_font_size, 'tooltip_font_size': tooltip_font_size } self.write(self.get_rendered_html(path, template_values), 200)
def get(self): q = Company.all() companies = [] domain = {'influence' : [0, 1], 'expertise' : [0, 1], 'size' : [0, 5]} for c in q.fetch(100): curr_c = {} curr_c['name'] = c.name curr_c['influence'] = c.influence_avg curr_c['expertise'] = get_skills_json(c.get_expertise_avg()) curr_c['id'] = c.key().id() curr_c['size'] = self.get_size_for(c) companies.append(curr_c) ret_val = {'companies' : companies, 'domain' : domain} self.write(json.dumps(ret_val))
def get(self): path = 'startups_latest.html' q = Company.all() logging.info(q.count()) companies = [self.make_dict(company) for company in q] companies.insert( 0, { 'image': '/assets/img/new_startup.png', 'name': 'Your Startup', 'url': '/startups/registration/queue' }) sorted_company_rows = [ companies[i:i + 3] for i in range(0, len(companies), 3) ] template_values = { 'startups': sorted_company_rows, 'nav_color': 'dark-nav' } self.write(self.get_rendered_html(path, template_values), 200)
def get(self): path = 'startups_search_results.html' project_id = long(self['project_id']) project = Project.get_by_id(project_id) skills = project.skills q = Company.all() sorted_companies = {} for c in q.fetch(50): expertise_dict = convert_string_list_to_dict(c.expertise_avg) score = 0.0 matched_skills = 0.0 fit = 0.0 id = c.key().id() sorted_companies[id] = {} sorted_companies[id]['name'] = c.name sorted_companies[id]['influence'] = c.influence_avg sorted_companies[id]['skills'] = [] if skills: for skill in skills: skill = str(skill) if skill in expertise_dict: skill_dict = { 'name':skill,'value':float(expertise_dict[skill]) } score += float(expertise_dict[skill]) matched_skills += 1 else: skill_dict = { 'name':skill,'value':0.0 } sorted_companies[id]['skills'].append(skill_dict) score = float(score / len(skills)) fit = float(matched_skills / len(skills)) if matched_skills > 0.0 else 0.0 sorted_companies[id]['combined']=score sorted_companies[id]['fit']=fit donuts = (len(skills) if skills else 0) + 3 sorted_companies = sorted(sorted_companies.iteritems(), key=lambda (k,v): v['combined'], reverse = True) donut_size = 80-(5*donuts) score_font_size = 40-(2.25*donuts) tooltip_font_size = 14-donuts template_values = {'startups' : sorted_companies, 'skills' : skills, 'donut_size' : donut_size, 'score_font_size' : score_font_size, 'tooltip_font_size' : tooltip_font_size} self.write(self.get_rendered_html(path, template_values), 200)
def get_companies(self): q = Company.all() companies = [] for company in q.fetch(100): companies.append({'value' : company.key().id(), 'name' : company.name}) return companies