File tree 2 files changed +17
-5
lines changed
web2py/applications/utility/models
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -579,16 +579,16 @@ def sample_from_conditions(conditions, string):
579
579
580
580
'''
581
581
result = {}
582
- for i ,(k , v ) in enumerate (conditions .items ()):
582
+ for i ,(key , value ) in enumerate (conditions .items ()):
583
583
# Make sure each iteration gets different hash by prepending
584
584
# with str(i). By attaching to front, it won't get cut off in
585
585
# the substring operation [:7] in hash_to_bucket
586
586
s = str (i ) + string
587
587
588
- if is_singleton (v ):
589
- result [k ] = singleton (v )
590
- elif isinstance (v , list ):
591
- result [k ] = hash_to_bucket (s , v )
588
+ if is_singleton (value ):
589
+ result [key ] = singleton (value )
590
+ elif isinstance (value , list ):
591
+ result [key ] = hash_to_bucket (s , value )
592
592
else :
593
593
soft_assert (False , 'Bad condition' )
594
594
return result
Original file line number Diff line number Diff line change @@ -129,6 +129,18 @@ def update_ass_conditions():
129
129
130
130
131
131
# ============== From When Shit Hit Fans =============
132
+ def pay_worker_extra (workerid , amount , reason ):
133
+ ''' Finds a recent assignment that the worker completed and pays
134
+ him with it'''
135
+ ass = db ((db .actions .workerid == workerid )
136
+ & (db .actions .action == 'finished' )).select (orderby = ~ db .actions .time ,
137
+ limitby = (0 ,1 )).first ()
138
+ if not ass or not ass .assid :
139
+ log ('No assignment for worker %s' % workerid )
140
+ return
141
+
142
+ return turk .give_bonus (ass .assid , workerid , amount , reason )
143
+
132
144
def pay_poor_souls ():
133
145
poor_souls = db ((db .hits_log .creation_time < datetime (2009 , 12 , 28 ))
134
146
& (db .hits_log .creation_time > datetime (2009 , 11 , 1 ))
You can’t perform that action at this time.
0 commit comments