author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 18 Apr 2009 15:05:56 +0000 | |
changeset 2218 | 84b0ce492cf5 |
parent 2151 | f58515b0b2e1 |
child 2222 | a91d55e9c9cd |
permissions | -rwxr-xr-x |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Starts an interactive shell with statistic helpers. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
import cPickle |
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
26 |
import datetime |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
import operator |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
import sys |
2218
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
29 |
import time |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
import interactive |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
|
2058 | 34 |
def dateFetch(queryGen, last=None, batchSize=100): |
35 |
"""Iterator that yields an entity in batches. |
|
36 |
||
37 |
Args: |
|
38 |
queryGen: should return a Query object |
|
39 |
last: used to .filter() for last_modified_on |
|
40 |
batchSize: how many entities to retrieve in one datastore call |
|
41 |
||
42 |
Retrieved from http://tinyurl.com/d887ll (AppEngine cookbook). |
|
43 |
""" |
|
44 |
||
45 |
from google.appengine.ext import db |
|
46 |
||
47 |
# AppEngine will not fetch more than 1000 results |
|
48 |
batchSize = min(batchSize,1000) |
|
49 |
||
50 |
query = None |
|
51 |
done = False |
|
52 |
count = 0 |
|
53 |
||
54 |
while not done: |
|
55 |
print count |
|
56 |
query = queryGen() |
|
57 |
query.order('last_modified_on') |
|
58 |
if last: |
|
59 |
query.filter("last_modified_on > ", last) |
|
60 |
results = query.fetch(batchSize) |
|
61 |
for result in results: |
|
62 |
count += 1 |
|
63 |
yield result |
|
64 |
if batchSize > len(results): |
|
65 |
done = True |
|
66 |
else: |
|
67 |
last = results[-1].last_modified_on |
|
68 |
||
69 |
||
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
def addKey(target, fieldname): |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
"""Adds the key of the specified field. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
result = target.copy() |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
result['%s_key' % fieldname] = target[fieldname].key().name() |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
return result |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
|
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
79 |
def getEntities(model): |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
80 |
"""Returns all users as dictionary. |
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
81 |
""" |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
82 |
|
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
83 |
def wrapped(): |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
84 |
gen = lambda: model.all() |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
85 |
it = interactive.deepFetch(gen) |
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
86 |
|
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
87 |
entities = [(i.key().name(), i) for i in it] |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
88 |
return dict(entities) |
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
89 |
|
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
90 |
return wrapped |
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
91 |
|
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
92 |
|
2062
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
93 |
def getProps(last=None): |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
"""Returns all proposals as a list of dictionaries. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
95 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
key_order = [ |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
98 |
'link_id', 'scope_path', 'title', 'abstract', 'content', |
2062
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
99 |
'additional_info', '_mentor', 'possible_mentors', 'score', |
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
100 |
'status', '_org', 'created_on', 'last_modified_on'] |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
101 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
102 |
from soc.models.student_proposal import StudentProposal |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
103 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
gen = lambda: StudentProposal.all() |
2062
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
105 |
|
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
106 |
it = dateFetch(gen, last) |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
|
2062
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
108 |
proposals = [(i.key().name(), i.toDict(key_order)) for i in it] |
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
109 |
if proposals: |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
110 |
last = i.last_modified_on # last modified entity |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
111 |
else: |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
112 |
last = datetime.datetime.now() |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
113 |
|
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
114 |
return dict(proposals), last |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
116 |
|
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
117 |
def orgStats(target, orgs): |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
"""Retrieves org stats. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
121 |
from soc.logic import dicts |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
|
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
123 |
orgs = [(v.key(), v) for k, v in orgs.iteritems()] |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
124 |
orgs = dict(orgs) |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
125 |
|
2062
9c739b37c367
Refactor getProps to use dateFetch
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2061
diff
changeset
|
126 |
grouped = dicts.groupby(target.values(), '_org') |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
|
2079
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
128 |
grouped = [(orgs[k], v) for k, v in grouped.iteritems()] |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
129 |
popularity = [(k.link_id, len(v)) for k, v in grouped] |
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
130 |
|
086c60aad3d8
Minor tweaks to orgStats
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2063
diff
changeset
|
131 |
return dict(grouped), dict(popularity) |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
|
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
134 |
def countStudentsWithProposals(): |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
135 |
"""Retrieves number of Students who have submitted at least one Student Proposal. |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
136 |
""" |
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
137 |
|
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
138 |
proposals = getStudentProposals() |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
139 |
students = {} |
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
140 |
|
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
141 |
for proposal_key in proposals.keys(): |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
142 |
students[proposals[proposal_key].scope_path] = True |
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
143 |
|
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
144 |
return len(students) |
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
145 |
|
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
146 |
|
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
147 |
def printPopularity(popularity): |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
148 |
"""Prints the popularity for the specified proposals. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
150 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
151 |
g = operator.itemgetter(1) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
152 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
153 |
for item in sorted(popularity.iteritems(), key=g, reverse=True): |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
154 |
print "%s: %d" % item |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
155 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
156 |
|
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
157 |
def saveValues(values, saver): |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
158 |
"""Saves the specified popularities. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
159 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
160 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
161 |
import logging |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
162 |
from google.appengine.ext import db |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
163 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
164 |
from soc.models.organization import Organization |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
165 |
|
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
166 |
def txn(key, value): |
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
167 |
org = Organization.get_by_key_name(key) |
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
168 |
saver(org, value) |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
169 |
org.put() |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
170 |
|
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
171 |
for key, value in sorted(values.iteritems()): |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
172 |
print key |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
173 |
db.run_in_transaction_custom_retries(10, txn, key, value) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
174 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
175 |
print "done" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
176 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
177 |
|
2090
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
178 |
def addFollower(follower, proposals, add_public=True, add_private=True): |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
179 |
"""Adds a user as follower to the specified proposals. |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
180 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
181 |
Args: |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
182 |
follower: the User to add as follower |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
183 |
proposals: a list with the StudnetProposals that should be subscribed to |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
184 |
add_public: whether the user is subscribed to public updates |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
185 |
add_private: whether the user should be subscribed to private updates |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
186 |
""" |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
187 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
188 |
from soc.models.review_follower import ReviewFollower |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
189 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
190 |
result = [] |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
191 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
192 |
for i in proposals: |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
193 |
properties = { |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
194 |
'user': follower, |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
195 |
'link_id': follower.link_id, |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
196 |
'scope': i, |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
197 |
'scope_path': i.key().name(), |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
198 |
'key_name': '%s/%s' % (i.key().name(), follower.link_id), |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
199 |
'subscribed_public': add_public, |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
200 |
'subscribed_private': add_private, |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
201 |
} |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
202 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
203 |
entity = ReviewFollower(**properties) |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
204 |
result.append(entity) |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
205 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
206 |
return result |
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
207 |
|
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
208 |
|
2218
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
209 |
def convertProposals(org): |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
210 |
"""Convert all proposals for the specified organization. |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
211 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
212 |
Args: |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
213 |
org: the organization for which all proposals will be converted |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
214 |
""" |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
215 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
216 |
from soc.logic.models.student_proposal import logic as proposal_logic |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
217 |
from soc.logic.models.student_project import logic as project_logic |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
218 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
219 |
proposals = proposal_logic.getProposalsToBeAcceptedForOrg(org) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
220 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
221 |
for proposal in proposals: |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
222 |
fields = { |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
223 |
'link_id': 't%i' % (int(time.time()*100)), |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
224 |
'scope_path': proposal.org.key().id_or_name(), |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
225 |
'scope': proposal.organization, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
226 |
'program': proposal.program, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
227 |
'student': proposal.scope, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
228 |
'title': proposal.title, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
229 |
'abstract': proposal.abstract, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
230 |
'mentor': proposal.mentor, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
231 |
} |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
232 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
233 |
project = project_logic.updateOrCreateFromFields(fields) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
234 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
235 |
fields = { |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
236 |
'status':'accepted', |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
237 |
} |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
238 |
proposal_logic.updateEntityProperties(proposal, fields) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
239 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
240 |
fields = { |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
241 |
'status': ['new', 'pending', 'invalid'], |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
242 |
'org': org, |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
243 |
} |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
244 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
245 |
query = proposal_logic.getQueryForFields(filter) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
246 |
proposals = interactive.deepFetch(query) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
247 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
248 |
fields = { |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
249 |
'status': 'rejected', |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
250 |
} |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
251 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
252 |
for proposal in proposals: |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
253 |
proposal_logic.updateEntityProperties(proposal, fields) |
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
254 |
|
84b0ce492cf5
Add a script to convert proposals.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2151
diff
changeset
|
255 |
|
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
256 |
def loadPickle(name): |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
257 |
"""Loads a pickle. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
258 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
259 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
260 |
f = open(name + '.dat') |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
261 |
return cPickle.load(f) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
262 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
263 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
264 |
def dumpPickle(target, name): |
2061 | 265 |
"""Dumps a pickle. |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
266 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
267 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
268 |
f = open("%s.dat" % name, 'w') |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
269 |
cPickle.dump(target, f) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
270 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
271 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
272 |
def main(args): |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
273 |
"""Main routine. |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
274 |
""" |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
275 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
276 |
interactive.setup() |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
277 |
|
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
278 |
from soc.models.organization import Organization |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
279 |
from soc.models.user import User |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
280 |
from soc.models.student import Student |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
281 |
from soc.models.mentor import Mentor |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
282 |
from soc.models.org_admin import OrgAdmin |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
283 |
|
2151
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
284 |
def slotSaver(org, value): |
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
285 |
org.slots = value |
2151
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
286 |
def popSaver(org, value): |
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
287 |
org.nr_applications = value |
2151
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
288 |
def rawSaver(org, value): |
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
289 |
org.slots_calculated = value |
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
290 |
|
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
291 |
context = { |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
292 |
'load': loadPickle, |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
293 |
'dump': dumpPickle, |
2052
a723a2509e21
Add some additional functions for stats to stats.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2047
diff
changeset
|
294 |
'orgStats': orgStats, |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
295 |
'printPopularity': printPopularity, |
2148
0345046ed7a5
Make it possible to save any value with saveValues
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2090
diff
changeset
|
296 |
'saveValues': saveValues, |
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
297 |
'getOrgs': getEntities(Organization), |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
298 |
'getUsers': getEntities(User), |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
299 |
'getStudents': getEntities(Student), |
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
300 |
'getMentors': getEntities(Mentor), |
2063
319d9f05955a
Fixed a typo in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2062
diff
changeset
|
301 |
'getOrgAdmins': getEntities(OrgAdmin), |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
302 |
'getProps': getProps, |
2060
45029d87be4a
Add and use a getEntities method
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2058
diff
changeset
|
303 |
'countStudentsWithProposals': countStudentsWithProposals, |
2090
a07ff1e1bd1f
Add a script to subscribe someone to all updates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2089
diff
changeset
|
304 |
'addFollower': addFollower, |
2089
b8a9691da6e7
Add the entities to the context too
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2079
diff
changeset
|
305 |
'Organization': Organization, |
b8a9691da6e7
Add the entities to the context too
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2079
diff
changeset
|
306 |
'User': User, |
b8a9691da6e7
Add the entities to the context too
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2079
diff
changeset
|
307 |
'Student': Student, |
b8a9691da6e7
Add the entities to the context too
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2079
diff
changeset
|
308 |
'Mentor': Mentor, |
b8a9691da6e7
Add the entities to the context too
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2079
diff
changeset
|
309 |
'OrgAdmin': OrgAdmin, |
2151
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
310 |
'slotSaver': slotSaver, |
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
311 |
'popSaver': popSaver, |
f58515b0b2e1
Style fix in function names in stats.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2148
diff
changeset
|
312 |
'rawSaver': rawSaver, |
2047
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
313 |
} |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
314 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
315 |
interactive.remote(args, context) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
316 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
317 |
if __name__ == '__main__': |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
318 |
if len(sys.argv) < 2: |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
319 |
print "Usage: %s app_id [host]" % (sys.argv[0],) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
320 |
sys.exit(1) |
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
321 |
|
7e9656691c8e
Added a stats module to scripts
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
322 |
main(sys.argv[1:]) |