Nick Stenning avatar Nick Stenning committed 256f3e2

[load] fix EPSRC loader

Comments (0)

Files changed (1)

wdmmgext/load/epsrc.py

 
 def make_loader():
     """Returns a loader for this dataset"""
-    loader = Loader(DATASET_NAME, u"Engineering and Physical Research Sciences Council",
+    loader = Loader(DATASET_NAME, ["name"], u"Engineering and Physical Research Sciences Council",
         description=u'''Research grants from the EPRSC between 1985 and 2011''', currency="GBP")
     return loader
 
 
     def describe_dimension(key, label, description=None):
         loader.create_dimension(key, label, description=description)
-    
+
    # Retrieve or create the required Keys.
     describe_dimension(u'from', 'Grant from', description=u'''\
 The entity that gave the grant.''')
 The accounting period for which the grant was given.''')
     describe_dimension(u'department', u"The department the grant was given to")
     describe_dimension(u'organisation', u"The organisation that received the grant")
-    
-    epsrc = loader.create_entity(name=u'epsrc', 
-        label=u'Engineering and Physical Research Council',
-        description=u'''EPSRC Entity that gives grants'''
+
+    epsrc = loader.create_entity(name=u'epsrc',
+        label=u'EPSRC',
+        description=u'''UK Engineering and Physical Sciences Research Council'''
     )
-     
+
     cursor = connection.cursor()
     cols = ('grant_id', 'label', 'amount', 'piid', 'oid', 'depid', 'principal_name',
             'department_name', 'department_orgid', 'organisation_name')
-    cursor.execute('''SELECT g.id as grant_id, g.title AS label, g.value AS amount, 
-            g.principal_investigator_id AS piid, g.organisation_id AS oid,
-            g.department_id AS depid, p.name AS principal_name, d.name AS department_name, 
+    cursor.execute('''SELECT g.id as grant_id, g.title AS label, g.value AS amount,
+            g.principal_investigator_id AS piid, d.organisation_id AS oid,
+            g.department_id AS depid, p.name AS principal_name, d.name AS department_name,
             d.organisation_id AS dep_orgid, o.name AS organisation_name
             FROM grants AS g
             LEFT JOIN people AS p ON p.id = piid
     entry_id = -1
 
     dummy_time = times.for_year(2010)
-    
+
     for row in cursor:
         entry_id += 1
         mapping = dict([(k,v) for k,v in zip(cols, row)])
-        
+
         principal_id = u"%s-%s" % (mapping["piid"], munge.to_name(mapping["principal_name"]))
 
         additional_entity = {
             epsrc_organisation=True,
             epsrc_organisation_id=mapping["oid"]
         )
- 
+
         entry_dict = {
             'name': u"%s-%s-%s" % (DATASET_NAME, entry_id, munge.to_name(mapping["grant_id"])),
             'label': mapping["label"],
             "principal_id": mapping["piid"]
         }
 
-        q = {'name': entry_dict.get('name')}
-        loader.create_entry(q, **entry_dict)
+        loader.create_entry(**entry_dict)
 
     aggregate(loader)
 
        loader = make_loader()
 
     loader.flush_aggregates()
-    loader.create_view(Dataset, {'name': DATASET_NAME}, name='default', 
-                       label="Grants by Organisation", 
+    loader.create_view(Dataset, {'name': DATASET_NAME}, name='default',
+                       label="Grants by Organisation",
                        dimension="dataset", breakdown="organisation")
-    loader.create_view(Entity, {'epsrc_organisation': True}, name='default', 
-                       label="Grants by Department", 
+    loader.create_view(Entity, {'epsrc_organisation': True}, name='default',
+                       label="Grants by Department",
                        dimension="organisation", breakdown="department")
-    loader.create_view(Entity, {'epsrc_department': True}, name='default', 
-                       label="Grants by Principal Investigator", 
+    loader.create_view(Entity, {'epsrc_department': True}, name='default',
+                       label="Grants by Principal Investigator",
                        dimension="department", breakdown="to")
-    loader.create_view(Entity, {'epsrc_researcher': True}, name='default', 
-                       label="Grants by Project", 
-                       dimension="to", breakdown="label")
+    # loader.create_view(Entity, {'epsrc_researcher': True}, name='default',
+    #                    label="Grants by Project",
+    #                    dimension="to", breakdown="label")
     #TODO: needs more views on data
 
     loader.compute_aggregates()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.