Skip to content

Commit

Permalink
Fix lint issues in virginiaogda (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jguo144 authored Nov 27, 2023
1 parent 6b9b642 commit 049ea32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
16 changes: 8 additions & 8 deletions ckanext/opendata_theme/extended_themes/virginiaogda/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging

import ckan.lib.helpers as h
from ckan.lib.plugins import toolkit as tk
import ckan.model as model
from ckan.lib.search import make_connection

Expand All @@ -12,6 +11,7 @@

log = logging.getLogger(__name__)


def get_featured_datasets():
"""
Returns a list of featured datasets
Expand All @@ -24,27 +24,28 @@ def get_featured_datasets():
.filter(PackageExtra.value == 'yes')\
.filter(Package.state == 'active')\
.filter(Package.private == False)\
.order_by(PackageExtra.value) \
.all()
.order_by(PackageExtra.value)\
.all() # noqa: E712
except Exception as e:
logging.error('Error getting featured datasets: %s', e)
featured_datasets_dict_list = h.convert_to_dict('package',featured_datasets)
featured_datasets_dict_list = h.convert_to_dict('package', featured_datasets)
return featured_datasets_dict_list


def get_all_resource_count():
"""
Returns a sum of all resources
"""
q = model.Session.query(model.Resource).filter(model.Resource.state == 'active')

data = {'total_resources': q.count()}
return data


def get_contributors_count():
solr = make_connection()

total = 0 # total number of contributors
total = 0 # total number of contributors
results = (
solr.search(
'*:*',
Expand Down Expand Up @@ -78,7 +79,7 @@ def get_contributors_count():
# order the solr facets by created date
order = list(
model.Session.query(model.Package.id, model.Package.metadata_created)
.filter(model.Package.private == False)
.filter(model.Package.private == False) # noqa: E712
.filter(model.Package.state == model.State.ACTIVE)
.order_by(model.Package.metadata_created)
)
Expand All @@ -87,4 +88,3 @@ def get_contributors_count():
total += counts.get(package_id, 0)
log.info('Total number of contributors: %s', total)
return total

13 changes: 3 additions & 10 deletions ckanext/opendata_theme/extended_themes/virginiaogda/plugin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import datetime
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
import logging
import ckan.model as model
import ckan.lib.helpers as h
import ckanext.opendata_theme.extended_themes.virginiaogda.helpers as vh

from ckan.model.package import Package
from ckan.model.package_extra import PackageExtra
import ckanext.opendata_theme.extended_themes.virginiaogda.helpers as vh


class OpenDataThemePlugin(plugins.SingletonPlugin):
Expand All @@ -20,11 +13,11 @@ def update_config(self, config):
toolkit.add_template_directory(config, 'templates')
toolkit.add_public_directory(config, 'public')


# ITemplateHelpers

def get_helpers(self):
return {
'opendata_theme_get_featured_datasets': vh.get_featured_datasets,
'opendata_theme_get_all_resource_count': vh.get_all_resource_count,
'opendata_theme_get_contributors_count': vh.get_contributors_count,
}
}

0 comments on commit 049ea32

Please sign in to comment.