def get_star_html(self, resource_id): from ckanext.qa import reports report = reports.resource_five_stars(resource_id) stars = report.get('openness_score', -1) if stars >= 0: reason = report.get('openness_score_reason') return html.get_star_html(stars, reason) return None
def get_resource_openness(resource_id): stars = 0 reason = plugins.toolkit._('Not Rated') updated = "" if resource_id: resource_report = reports.resource_five_stars(resource_id) stars = resource_report.get('openness_score', -1) updated = resource_report.get('openness_updated') if stars >= 0: reason = resource_report.get('openness_score_reason') extra_vars = {'stars': stars, 'reason': reason, 'updated': updated} return extra_vars
def get_dataset_openness(dataset_id): # Obtener el mayor report de todos los resource del dataset #report = reports.five_stars(dataset_id) dataset_report = five_stars(dataset_id) id_max_resource = '' max_star = 0 stars = 0 reason = plugins.toolkit._('Not Rated') updated = "" for resource in dataset_report: if resource.get('openness_score', -1) > max_star: max_star = resource.get('openness_score', -1) id_max_resource = resource.get('resource_id','') if id_max_resource: resource_report = reports.resource_five_stars(id_max_resource) stars = resource_report.get('openness_score', -1) updated = resource_report.get('openness_updated') if stars >= 0: reason = resource_report.get('openness_score_reason') extra_vars = {'stars': stars, 'reason': reason, 'updated': updated} return extra_vars
def resource_five_stars(self, id): return json.dumps(resource_five_stars(id))
def resource_five_stars(self, id): result = resource_five_stars(id) return self._output_json(result)