Permalink
Browse files

Merge branch 'develop' of https://github.com/localprojects/Change-By-Us

… into develop
  • Loading branch information...
2 parents 0fa146f + c34dcb9 commit e7928c6ae2ceff864e75d37a104e3b783b29bad9 Ethan Holda committed Apr 5, 2012
Showing with 20 additions and 21 deletions.
  1. +3 −0 fabfile.py
  2. +17 −21 giveaminute/location.py
View
@@ -89,6 +89,9 @@
# SSH Key configuration
env.key_filename = os.path.expanduser(env.key_filename)
+while not os.path.exists(env.key_filename):
+ env.key_filename = prompt("Keffile %s not found. Provide valid SSH keyfile (eg. ~/.ssh/ChangeByUs.pem: " % env.key_filename)
+ env.key_filename = os.path.expanduser(env.key_filename)
env.ssh_port = 48022
# We need to make the hosts into a list
View
@@ -14,26 +14,22 @@ def getLocationsWithScoring(db):
# TODO
# this is temporary until actual scoring is determined
sql = """
-select l.location_id
- ,l.name
- ,l.lat
- ,l.lon
- ,(select count(*) as count
- from project p
- inner join project__user opu on opu.project_id = p.project_id and opu.is_project_admin = 1
- where
- p.is_active = 1
- and p.location_id = l.location_id) as num_projects
- ,(select count(*) as count
- from idea i
- where
- i.is_active = 1
- and i.location_id = l.location_id) as num_ideas
- ,(select count(*) as count
- from project_resource r
- where
- r.is_active = 1 and r.is_hidden = 0 and r.location_id = l.location_id) as num_project_resources
-from location l where l.location_id > 0""";
+select l.location_id,
+ l.name,
+ l.lat,
+ l.lon,
+ count(distinct p.project_id) as num_projects,
+ count(distinct i.idea_id) as num_ideas,
+ count(distinct r.project_resource_id) as num_project_resources
+from location l
+ left join project p on p.location_id = l.location_id and p.is_active=1
+ left join project__user pu on p.project_id=pu.project_id and pu.is_project_admin = 1 and p.is_active=1
+ left join idea i on l.location_id = i.location_id and i.is_active=1
+ left join project_resource r on l.location_id = r.location_id and r.is_active=1 and r.is_hidden=0
+where l.location_id > 0
+group by l.location_id+l.lat+l.lon
+order by l.location_id""";
+
data = list(db.query(sql))
except Exception, e:
log.info("*** couldn't get locations")
@@ -84,4 +80,4 @@ def getSimpleLocationDictionary(db):
return locations
-
+

0 comments on commit e7928c6

Please sign in to comment.