Exemple #1
0
 def _filter_report_using_year(self, reportDescription, report, year):
     query = ReportQueryModel(reportDescription)
     for kword in query.keywords():
         for thread in report[kword]:
             threadobj = ThreadModel(thread)
             new_msgs = self._filer_msgs_in(threadobj, year)
             threadobj.replace_msgs_objs(new_msgs)
Exemple #2
0
 def build_report(self, report_request):
     """ This mehtod should return a json
     """
     report_obj = self._create_empty_report(report_request)
     #report_obj = ReportModel(report_json)
     report_query = ReportQueryModel(report_request)
     stats = ReportStats()
     for module in self.report_modules:
         module.build_report(report_request, report_obj, stats)
     self._save_stats(report_query.name(), stats)
     self._filter_report(report_query, report_obj)
     self.sorting_service.sort_report(report_query.keywords(), report_obj)
     return ReportResult(report_obj.json(), stats)
Exemple #3
0
 def _filter_threads_using_year(self, reportDescription, report, year):
     """ Previous method filter messages of a thread.
         this method filters therads in a report.
         Don't word modifyng directy the report so I retorn the JSon again
     """
     year_int = int(year)
     query = ReportQueryModel(reportDescription)
     report_obj = ReportModel(report)
     for kword in query.keywords():
         threats = list()
         for threadobj in report_obj.threads_in(kword):
             #print kword, ":", threadobj.year_last_msg(), ", ", year_int, threadobj.link()
             if threadobj.year_last_msg() > year_int:
                 threats.append(threadobj.json())
         report_obj.set_threads_to(kword, threats)
     return report_obj.json()