Skip to content

Commit

Permalink
add status and minor data-out reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
alee committed Sep 22, 2015
1 parent 8d0441b commit dba47f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions catalog/core/management/commands/export_data.py
Expand Up @@ -10,7 +10,7 @@


class Command(BaseCommand):
help = 'Exports data to a csv file'
help = '''Exports data to a csv file. '''

def find_max(self, attribute):
return Publication.objects.annotate(num=Count(attribute)).order_by('-num')[0].num
Expand All @@ -31,7 +31,7 @@ def get_attribute_values(self, attributes, max_value):

def handle(self, *args, **options):
logger.debug("Starting to export data. Hang tight, this may take a while.")
header = ["Publication Year", "Publication Title", "Journal Title", "Primary Author", "Code Url", "Docs"]
header = ["Status", "Publication Title", "Code Url", "Publication Year", "Journal Title", "Primary Author", "Docs"]
max_platforms = self.find_max('platforms')
max_sponsors = self.find_max('sponsors')
header.extend(self.get_attribute_headers("Platform", max_platforms))
Expand All @@ -43,8 +43,8 @@ def handle(self, *args, **options):
writer = csv.writer(csvfile, delimiter=',')
writer.writerow(header)
for pub in publications:
row = [pub.date_published.year or pub.date_published_text, pub.title, str(pub.journal),
str(pub.creators.all()[0]), pub.code_archive_url, str(pub.model_documentation)]
row = [pub.status, pub.title, pub.code_archive_url, pub.date_published.year or pub.date_published_text,
str(pub.journal), str(pub.creators.all()[0]), str(pub.model_documentation)]
row.extend(self.get_attribute_values(pub.platforms.all(), max_platforms))
row.extend(self.get_attribute_values(pub.sponsors.all(), max_sponsors))
writer.writerow(row)
Expand Down
16 changes: 14 additions & 2 deletions package.json
@@ -1,8 +1,18 @@
{
"name": "@comses/catalog",
"version": "v0.5.1",
"contributors": [
{"name": "Allen Lee", "email": "allen.lee@asu.edu"}
],
"repository": {
"type": "git",
"url": "https://github.com/comses/catalog"
},
"license": "GPLv2",
"dependencies": {
"react": "latest",
"reflux": "latest",
"superagent": "latest",
"react-select": "latest"
},
"browserify": {
Expand All @@ -17,7 +27,9 @@
"mocha": "latest"
},
"scripts": {
"lint": "jshint **.js",
"test": "mocha catalog/static/js/tests/"
"lint": "jshint catalog/js/**.js",
"test": "mocha catalog/js/tests/",
"build": "browserify -t reactify js/app.js -o miracle/static/js/catalog.min.js",
"prepublish": "npm run build"
}
}

0 comments on commit dba47f0

Please sign in to comment.