def GetTopBounties(self, fetcher, page): newBounties, lastFetchingTime = fetcher(page) bountiesToCache = [ bounty for bounty in newBounties if self.IsObsolete(bounty.targetID, lastFetchingTime) ] self.LogInfo('GetTopBounties::Got', len(newBounties), 'but caching', len(bountiesToCache)) bountyUtil.CacheBounties(self.bounties, bountiesToCache) return sorted(newBounties, key=lambda x: x.bounty, reverse=True)
def SearchBounties(self, targetID): if util.IsCharacter(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchCharBounties elif util.IsCorporation(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchCorpBounties elif util.IsAlliance(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchAllianceBounties bountyAndRank = fetcher(targetID) bountyUtil.CacheBounties(self.bounties, [bounty for rank, bounty in bountyAndRank]) return bountyAndRank
def FetchBounties(self, targetIDs): bountiesToUpdate = { targetID for targetID in targetIDs if self.IsObsolete(targetID) } self.LogInfo('FetchBounties - Got', len(bountiesToUpdate), 'that are not cached or expired') if bountiesToUpdate: bounties = [ bounty for targetID, bounty in self.GetBountiesFromServer( bountiesToUpdate) ] bountyUtil.CacheBounties(self.bounties, bounties)
def FetchBountiesAndKillRightsFromServer(self, charIDs, ownerIDs): bountiesToFetch = { ownerID for ownerID in ownerIDs if self.IsObsolete(ownerID) } killRightsToFetch = self.killRightTracker.GetInvalidKillRights(charIDs) self.LogInfo('FetchBountiesAndKillRightsFromServer - fetching', len(bountiesToFetch), 'for bounties and', len(killRightsToFetch), 'for killRights') if not (bountiesToFetch or killRightsToFetch): self.LogInfo( 'FetchBountiesAndKillRightsFromServer - Bailing out because nothing to fetch' ) return myKillRights, (bounties, killRights) = uthread.parallel([ (self.GetMyKillRights, ()), (sm.ProxySvc('bountyProxy').GetBountiesAndKillRights, (bountiesToFetch, killRightsToFetch)) ]) bountyUtil.CacheBounties(self.bounties, [bounty for targetID, bounty in bounties]) self.killRightTracker.CacheKillRights(killRights, killRightsToFetch)
def AddToBounty(self, ownerID, amount): newBounty = sm.ProxySvc('bountyProxy').AddToBounty(ownerID, amount) bountyUtil.CacheBounties(self.bounties, [newBounty]) sm.GetService('objectCaching').InvalidateCachedMethodCall( 'bountyProxy', 'GetMyBounties')