add a 'ratio' field
This commit is contained in:
parent
3f48882844
commit
db230bcc36
1 changed files with 10 additions and 0 deletions
|
|
@ -71,6 +71,15 @@ class FieldPopu(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
return unicode(profile['popu'][self.key])
|
return unicode(profile['popu'][self.key])
|
||||||
|
|
||||||
|
class FieldPopuRatio(FieldBase):
|
||||||
|
def get_value(self, profile, consts):
|
||||||
|
v1 = float(profile['popu'][self.key])
|
||||||
|
v2 = float(profile['popu'][self.key2])
|
||||||
|
if v2 == 0.0:
|
||||||
|
return 'NaN'
|
||||||
|
else:
|
||||||
|
return '%.2f' % (v1 / v2)
|
||||||
|
|
||||||
class FieldOld(FieldBase):
|
class FieldOld(FieldBase):
|
||||||
def get_value(self, profile, consts):
|
def get_value(self, profile, consts):
|
||||||
birthday = parse_dt(profile[self.key])
|
birthday = parse_dt(profile[self.key])
|
||||||
|
|
@ -140,6 +149,7 @@ class Contact(_Contact):
|
||||||
('invits', FieldPopu('invits')),
|
('invits', FieldPopu('invits')),
|
||||||
('bonus', FieldPopu('bonus')),
|
('bonus', FieldPopu('bonus')),
|
||||||
('score', FieldPopu('popu')),
|
('score', FieldPopu('popu')),
|
||||||
|
('ratio', FieldPopuRatio('mails', 'flashs')),
|
||||||
))),
|
))),
|
||||||
('details', OrderedDict((
|
('details', OrderedDict((
|
||||||
('old', FieldOld('birthday')),
|
('old', FieldOld('birthday')),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue