Fixed bug #2598: Cloud gramplets didn't show exactly the right set of names
svn: r11616
This commit is contained in:
parent
2fadd11aab
commit
48fb1c94f4
@ -301,6 +301,7 @@ class SurnameCloudGramplet(Gramplet):
|
|||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
self.set_text(_("Processing...") + "\n")
|
self.set_text(_("Processing...") + "\n")
|
||||||
|
yield True
|
||||||
people = self.dbstate.db.get_person_handles(sort_handles=False)
|
people = self.dbstate.db.get_person_handles(sort_handles=False)
|
||||||
surnames = {}
|
surnames = {}
|
||||||
representative_handle = {}
|
representative_handle = {}
|
||||||
@ -334,8 +335,6 @@ class SurnameCloudGramplet(Gramplet):
|
|||||||
for (count, surname) in surname_sort:
|
for (count, surname) in surname_sort:
|
||||||
cloud_names.append( (count, surname) )
|
cloud_names.append( (count, surname) )
|
||||||
cloud_values.append( count )
|
cloud_values.append( count )
|
||||||
if cnt > self.top_size:
|
|
||||||
break
|
|
||||||
cnt += 1
|
cnt += 1
|
||||||
cloud_names.sort(lambda a,b: cmp(a[1], b[1]))
|
cloud_names.sort(lambda a,b: cmp(a[1], b[1]))
|
||||||
counts = list(set(cloud_values))
|
counts = list(set(cloud_values))
|
||||||
@ -343,8 +342,27 @@ class SurnameCloudGramplet(Gramplet):
|
|||||||
counts.reverse()
|
counts.reverse()
|
||||||
line = 0
|
line = 0
|
||||||
### All done!
|
### All done!
|
||||||
|
# Now, find out how many we can display without going over top_size:
|
||||||
|
totals = {}
|
||||||
|
for (count, givensubname) in cloud_names: # givensubname_sort:
|
||||||
|
totals[count] = totals.get(count, 0) + 1
|
||||||
|
sums = totals.keys()
|
||||||
|
sums.sort()
|
||||||
|
sums.reverse()
|
||||||
|
total = 0
|
||||||
|
include_greater_than = 0
|
||||||
|
for s in sums:
|
||||||
|
if total + totals[s] <= self.top_size:
|
||||||
|
total += totals[s]
|
||||||
|
else:
|
||||||
|
include_greater_than = s
|
||||||
|
break
|
||||||
|
# Ok, now we can show those counts > include_greater_than:
|
||||||
|
print
|
||||||
|
showing = 0
|
||||||
self.set_text("")
|
self.set_text("")
|
||||||
for (count, surname) in cloud_names: # surname_sort:
|
for (count, surname) in cloud_names: # surname_sort:
|
||||||
|
if count > include_greater_than:
|
||||||
if len(surname) == 0:
|
if len(surname) == 0:
|
||||||
text = Config.get(Config.NO_SURNAME_TEXT)
|
text = Config.get(Config.NO_SURNAME_TEXT)
|
||||||
else:
|
else:
|
||||||
@ -355,11 +373,10 @@ class SurnameCloudGramplet(Gramplet):
|
|||||||
int((float(count)/total) * 100),
|
int((float(count)/total) * 100),
|
||||||
count))
|
count))
|
||||||
self.append_text(" ")
|
self.append_text(" ")
|
||||||
line += 1
|
showing += 1
|
||||||
if line >= self.top_size:
|
self.append_text(("\n\n" + _("Total unique surnames") + ": %d\n") %
|
||||||
break
|
|
||||||
self.append_text(("\n" + _("Total unique surnames") + ": %d\n") %
|
|
||||||
total_surnames)
|
total_surnames)
|
||||||
|
self.append_text((_("Total surnames showing") + ": %d\n") % showing)
|
||||||
self.append_text((_("Total people") + ": %d") % total_people, "begin")
|
self.append_text((_("Total people") + ": %d") % total_people, "begin")
|
||||||
|
|
||||||
class RelativesGramplet(Gramplet):
|
class RelativesGramplet(Gramplet):
|
||||||
|
@ -52,6 +52,7 @@ class GivenNameCloudGramplet(Gramplet):
|
|||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
self.set_text(_("Processing...") + "\n")
|
self.set_text(_("Processing...") + "\n")
|
||||||
|
yield True
|
||||||
people = self.dbstate.db.get_person_handles(sort_handles=False)
|
people = self.dbstate.db.get_person_handles(sort_handles=False)
|
||||||
givensubnames = {}
|
givensubnames = {}
|
||||||
representative_handle = {}
|
representative_handle = {}
|
||||||
@ -75,7 +76,7 @@ class GivenNameCloudGramplet(Gramplet):
|
|||||||
for givensubname in givensubnames:
|
for givensubname in givensubnames:
|
||||||
givensubname_sort.append( (givensubnames[givensubname], givensubname) )
|
givensubname_sort.append( (givensubnames[givensubname], givensubname) )
|
||||||
total += givensubnames[givensubname]
|
total += givensubnames[givensubname]
|
||||||
if cnt % 350 == 0:
|
if cnt % 100 == 0:
|
||||||
yield True
|
yield True
|
||||||
cnt += 1
|
cnt += 1
|
||||||
total_givensubnames = cnt
|
total_givensubnames = cnt
|
||||||
@ -86,8 +87,6 @@ class GivenNameCloudGramplet(Gramplet):
|
|||||||
for (count, givensubname) in givensubname_sort:
|
for (count, givensubname) in givensubname_sort:
|
||||||
cloud_names.append( (count, givensubname) )
|
cloud_names.append( (count, givensubname) )
|
||||||
cloud_values.append( count )
|
cloud_values.append( count )
|
||||||
if cnt > self.top_size:
|
|
||||||
break
|
|
||||||
cnt += 1
|
cnt += 1
|
||||||
cloud_names.sort(lambda a,b: cmp(a[1], b[1]))
|
cloud_names.sort(lambda a,b: cmp(a[1], b[1]))
|
||||||
counts = list(set(cloud_values))
|
counts = list(set(cloud_values))
|
||||||
@ -95,8 +94,26 @@ class GivenNameCloudGramplet(Gramplet):
|
|||||||
counts.reverse()
|
counts.reverse()
|
||||||
line = 0
|
line = 0
|
||||||
### All done!
|
### All done!
|
||||||
|
# Now, find out how many we can display without going over top_size:
|
||||||
|
totals = {}
|
||||||
|
for (count, givensubname) in cloud_names: # givensubname_sort:
|
||||||
|
totals[count] = totals.get(count, 0) + 1
|
||||||
|
sums = totals.keys()
|
||||||
|
sums.sort()
|
||||||
|
sums.reverse()
|
||||||
|
total = 0
|
||||||
|
include_greater_than = 0
|
||||||
|
for s in sums:
|
||||||
|
if total + totals[s] <= self.top_size:
|
||||||
|
total += totals[s]
|
||||||
|
else:
|
||||||
|
include_greater_than = s
|
||||||
|
break
|
||||||
|
# Ok, now we can show those counts > include_greater_than:
|
||||||
|
showing = 0
|
||||||
self.set_text("")
|
self.set_text("")
|
||||||
for (count, givensubname) in cloud_names: # givensubname_sort:
|
for (count, givensubname) in cloud_names: # givensubname_sort:
|
||||||
|
if count > include_greater_than:
|
||||||
if len(givensubname) == 0:
|
if len(givensubname) == 0:
|
||||||
text = Config.get(Config.NO_SURNAME_TEXT)
|
text = Config.get(Config.NO_SURNAME_TEXT)
|
||||||
else:
|
else:
|
||||||
@ -107,11 +124,10 @@ class GivenNameCloudGramplet(Gramplet):
|
|||||||
int((float(count)/total) * 100),
|
int((float(count)/total) * 100),
|
||||||
count))
|
count))
|
||||||
self.append_text(" ")
|
self.append_text(" ")
|
||||||
line += 1
|
showing += 1
|
||||||
if line >= self.top_size:
|
self.append_text(("\n\n" + _("Total unique given names") + ": %d\n") %
|
||||||
break
|
|
||||||
self.append_text(("\n" + _("Total unique given names") + ": %d\n") %
|
|
||||||
total_givensubnames)
|
total_givensubnames)
|
||||||
|
self.append_text((_("Total given names showing") + ": %d\n") % showing)
|
||||||
self.append_text((_("Total people") + ": %d") % total_people, "begin")
|
self.append_text((_("Total people") + ": %d") % total_people, "begin")
|
||||||
|
|
||||||
register(type="gramplet",
|
register(type="gramplet",
|
||||||
|
Loading…
Reference in New Issue
Block a user