summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Reports/importscript.py
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-06-03 14:59:34 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-06-03 10:07:57 -0500
commit8170fac20bedde567bf9cf482bca894ef97f8a07 (patch)
tree5531ab1004150c9052bf5125a2b05ab63964a664 /src/lib/Server/Reports/importscript.py
parent5d73365218e0cbca0befc9b030c31d0d4cea8f9c (diff)
downloadbcfg2-8170fac20bedde567bf9cf482bca894ef97f8a07.tar.gz
bcfg2-8170fac20bedde567bf9cf482bca894ef97f8a07.tar.bz2
bcfg2-8170fac20bedde567bf9cf482bca894ef97f8a07.zip
Performance updates to dynamic reports
Added bad_entries, modified_entries, extra_entries database fields to reduce the number of calls. Created (bad|modified|extra)_entry_count methods to return the sbove fields and populate any missing values. Consolidate interaction_per_client query. Added unique constraint on client_id and timestamp in Interaction. Greatly improved the performance of interaction_per_client. Modified detailed-list.html to add modified field and reduce the database calls to two... unless the bad_entries, modified_entries, extra_entries fields need updating. Modified client index to use only two database queries. Adding automatic update Updating load_stats to update counters in reports_interaction git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5885 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Reports/importscript.py')
-rwxr-xr-xsrc/lib/Server/Reports/importscript.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py
index 017bfd470..cc71837ea 100755
--- a/src/lib/Server/Reports/importscript.py
+++ b/src/lib/Server/Reports/importscript.py
@@ -114,11 +114,13 @@ def load_stats(cdata, sdata, vlevel, logger, quick=False, location=''):
timestamp, current_interaction.id))
+ counter_fields = { TYPE_CHOICES[0]: 0, TYPE_CHOICES[1]: 0, TYPE_CHOICES[2]: 0 }
pattern = [('Bad/*', TYPE_CHOICES[0]),
('Extra/*', TYPE_CHOICES[2]),
('Modified/*', TYPE_CHOICES[1]),]
for (xpath, type) in pattern:
for x in statistics.findall(xpath):
+ counter_fields[type] = counter_fields[type] + 1
kargs = build_reason_kwargs(x)
if not quick:
rls = Reason.objects.filter(**kargs)
@@ -158,6 +160,12 @@ def load_stats(cdata, sdata, vlevel, logger, quick=False, location=''):
if vlevel > 0:
logger.info("%s interaction created with reason id %s and entry %s" % (xpath, rr.id, entry.id))
+ # Update interaction counters
+ current_interaction.bad_entries = counter_fields[TYPE_CHOICES[0]]
+ current_interaction.modified_entries = counter_fields[TYPE_CHOICES[1]]
+ current_interaction.extra_entries = counter_fields[TYPE_CHOICES[2]]
+ current_interaction.save()
+
for times in statistics.findall('OpStamps'):
for metric, value in times.items():
if not quick: