def _analyseAndCache(self, board):
        boardList = DecisionModelProxy.GetBoardList()
        if board not in boardList:
            return NullBoardAnalysis()

        boardDecisions = DecisionModelProxy.GetAllForBoardOrderedByDecisionDate(
            board)
        count = len(boardDecisions)
        early = boardDecisions[:5]
        if count >= 5:
            late = boardDecisions[count - 5:]
        else:
            late = boardDecisions

        ipcTop5 = AnalysisHelpers.IpcMainFrequencyForBoard_TopN_withPercentage(
            board, 5, count)
        articleTop5 = AnalysisHelpers.AttributeFrequencyForBoard_TopN_withPercentage(
            board, 5, count)
        citationTop5 = AnalysisHelpers.ArticleFrequencyForBoard_TopN(board, 5)

        analysis = BoardAnalysis(board, count, early, late, ipcTop5,
                                 articleTop5, citationTop5)

        self._cache[board] = analysis
        return analysis
Exemple #2
0
 def test_GetAllForBoardOrderedByDecisionDate(self):
     from DecisionsPlus import DecisionModelProxy
     board = '3.5.07'
     result = DecisionModelProxy.GetAllForBoardOrderedByDecisionDate(board)
     for index in range(0, len(result) - 1):
         this = result[index].DecisionDate
         next = result[index + 1].DecisionDate
         self.assertTrue(this <= next,
                         'this {} not <= next {}'.format(this, next))
    def _analyseAndCache(self, board):
        boardList = DecisionModelProxy.GetBoardList()
        if board not in boardList:
            return NullBoardTimelineAnalysis()

        boardDecisions = DecisionModelProxy.GetAllForBoardOrderedByDecisionDate(
            board)
        if not boardDecisions:
            return EmptyBoardTimelineAnalysis(board)

        earliestDate = boardDecisions[0].DecisionDate
        latestDate = boardDecisions[-1].DecisionDate

        yearlyCases = {}
        for year in DateHelpers.YearIterator(earliestDate, latestDate):
            yearDecisions = [
                x for x in boardDecisions if x.DecisionDate.year == year.year
            ]
            yearCount = len(yearDecisions)
            yearlyCases[year.year] = yearCount
        result = BoardTimelineAnalysis(board, yearlyCases)
        self._cache[board] = result
        return result