async def _getAPIQueryFilter(self) -> List[dict]:
     ufdata = await self.find(finished=False)
     qf = None
     if len(ufdata) > 0:
         qf = []
         qd = {}
         for d in ufdata:
             cd = qd
             for k in ["season", "season_type", "week"]:
                 if not d[k] in cd:
                     cd[d[k]] = {}
                 cd = cd[d[k]]
         for s in qd:
             for st in qd[s]:
                 for w in qd[s][st]:
                     if st == "postseason" and w > 17:
                         if w == 22:
                             w = 4
                         else:
                             w = w - 17
                     qf.append({"season": s, "season_type": st, "week": w})
     elif len(await self.find(finished=True)) == 0 or len(await self.find()) == 0:
         qf = [{"season": s} for s in range(self._min_season, util.getSeason() + 1)]
     elif len(await self.find(seasons=[util.getSeason()])) == 0:
         # We don't have data for the current season so we need to query it
         qf = [{"season": util.getSeason()}]
     else:
         s = util.getSeason()
         st = "postseason"
         psrecs = await self.find(seasons=[s], season_types=[st])
         if len(psrecs) < 11:
             # more postseason games to come
             qf = []
             wks = set([r["week"] for r in psrecs])
             mw = 1
             if len(wks) > 0:
                 mw = min(wks) + 1
             for w in range(mw, 5):
                 qf.append({"season": s, "season_type": st, "week": w})
     return qf
Example #2
0
 def _getSeason(self, dt : datetime.datetime) -> int:
     return util.getSeason(dt)