Gets plaftform restrictions for the specified campaign feed.
3510
private static function getPlatformRestrictionsForCampaignFeed(
        $campaignFeed
    ) {
        $platformRestrictions = ExtensionSettingPlatform::NONE;

        if ($campaignFeed->getMatchingFunction()->getOperator() === FunctionOperator::AND_VALUE) {
            foreach ($campaignFeed->getMatchingFunction()->getLhsOperand() as $argument) {
                if ($argument instanceof FunctionOperand) {
                    if ($argument->getValue()->getOperator() === FunctionOperator::EQUALS
                        && $argument->getValue()->getLhsOperand()[0] instanceof RequestContextOperand) {
                        $requestContextOperand = $argument->getValue()->getLhsOperand()[0];
                        if ($requestContextOperand->getContextType()
                            === RequestContextOperandContextType::DEVICE_PLATFORM) {
                            $platformRestrictions = strtoupper(
                                $argument->getValue()->getRhsOperand()[0]->getStringValue()
                            );
                        }
                    }
                }
            }
        }

        return $platformRestrictions;
    }
749267
def get_team_push_restrictions(self):
        
        return github.PaginatedList.PaginatedList(
            github.Team.Team,
            self._requester,
            self.protection_url + "/restrictions/teams",
            None
        )
631054
private static List<CampaignFeed> getCampaignFeeds(AdWordsServicesInterface adWordsServices,
      AdWordsSession session, Feed feed, int placeholderType) throws RemoteException {
    // Get the CampaignFeedService.
    CampaignFeedServiceInterface campaignFeedService =
        adWordsServices.get(session, CampaignFeedServiceInterface.class);

    String query = String.format(
        "SELECT CampaignId, MatchingFunction, PlaceholderTypes WHERE Status = 'ENABLED' "
        + "AND FeedId = %d AND PlaceholderTypes CONTAINS_ANY [%d]", feed.getId(), placeholderType);

    List<CampaignFeed> campaignFeeds = new ArrayList<>();
    int offset = 0;
    CampaignFeedPage campaignFeedPage;

    do {
      String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
      campaignFeedPage = campaignFeedService.query(pageQuery);
      if (campaignFeedPage.getEntries() != null) {
        campaignFeeds.addAll(Arrays.asList(campaignFeedPage.getEntries()));
      }
      offset += PAGE_SIZE;
    } while (offset < campaignFeedPage.getTotalNumEntries());

    return campaignFeeds;
  }
174856
def get_user_push_restrictions(self):
        
        return github.PaginatedList.PaginatedList(
            github.NamedUser.NamedUser,
            self._requester,
            self.protection_url + "/restrictions/users",
            None
        )
330507
def restrict_to_routes(feed: "Feed", route_ids: List[str]) -> "Feed":
    
    # Initialize the new feed as the old feed.
    # Restrict its DataFrames below.
    feed = feed.copy()

    # Slice routes
    feed.routes = feed.routes[feed.routes["route_id"].isin(route_ids)].copy()

    # Slice trips
    feed.trips = feed.trips[feed.trips["route_id"].isin(route_ids)].copy()

    # Slice stop times
    trip_ids = feed.trips["trip_id"]
    feed.stop_times = feed.stop_times[
        feed.stop_times["trip_id"].isin(trip_ids)
    ].copy()

    # Slice stops
    stop_ids = feed.stop_times["stop_id"].unique()
    feed.stops = feed.stops[feed.stops["stop_id"].isin(stop_ids)].copy()

    # Slice calendar
    service_ids = feed.trips["service_id"]
    if feed.calendar is not None:
        feed.calendar = feed.calendar[
            feed.calendar["service_id"].isin(service_ids)
        ].copy()

    # Get agency for trips
    if "agency_id" in feed.routes.columns:
        agency_ids = feed.routes["agency_id"]
        if len(agency_ids):
            feed.agency = feed.agency[
                feed.agency["agency_id"].isin(agency_ids)
            ].copy()

    # Now for the optional files.
    # Get calendar dates for trips.
    if feed.calendar_dates is not None:
        feed.calendar_dates = feed.calendar_dates[
            feed.calendar_dates["service_id"].isin(service_ids)
        ].copy()

    # Get frequencies for trips
    if feed.frequencies is not None:
        feed.frequencies = feed.frequencies[
            feed.frequencies["trip_id"].isin(trip_ids)
        ].copy()

    # Get shapes for trips
    if feed.shapes is not None:
        shape_ids = feed.trips["shape_id"]
        feed.shapes = feed.shapes[
            feed.shapes["shape_id"].isin(shape_ids)
        ].copy()

    # Get transfers for stops
    if feed.transfers is not None:
        feed.transfers = feed.transfers[
            feed.transfers["from_stop_id"].isin(stop_ids)
            | feed.transfers["to_stop_id"].isin(stop_ids)
        ].copy()

    return feed
1360587
private function getLimitationTypes()
    {
        $limitationTypes = [];
        foreach ($this->policyMap as $module) {
            foreach ($module as $policy) {
                if (null === $policy) {
                    continue;
                }

                foreach (array_keys($policy) as $limitationType) {
                    if (!in_array($limitationType, $limitationTypes)) {
                        $limitationTypes[] = $limitationType;
                    }
                }
            }
        }

        return $limitationTypes;
    }
846173
private StringBuffer determineMethodsAllowed(String path) {

        StringBuffer methodsAllowed = new StringBuffer();
        boolean exists = true;
        I_CmsRepositoryItem item = null;
        try {
            item = m_session.getItem(path);
        } catch (CmsException e) {
            exists = false;
        }

        if (!exists) {

            methodsAllowed.append(METHOD_OPTIONS);
            methodsAllowed.append(", ").append(METHOD_PUT);
            methodsAllowed.append(", ").append(METHOD_MKCOL);
            methodsAllowed.append(", ").append(METHOD_LOCK);
            return methodsAllowed;
        }

        // add standard http methods
        methodsAllowed.append(METHOD_OPTIONS);
        methodsAllowed.append(", ").append(METHOD_GET);
        methodsAllowed.append(", ").append(METHOD_HEAD);
        methodsAllowed.append(", ").append(METHOD_POST);
        methodsAllowed.append(", ").append(METHOD_DELETE);
        methodsAllowed.append(", ").append(METHOD_TRACE);

        // add special WebDAV methods
        methodsAllowed.append(", ").append(METHOD_LOCK);
        methodsAllowed.append(", ").append(METHOD_UNLOCK);
        methodsAllowed.append(", ").append(METHOD_MOVE);
        methodsAllowed.append(", ").append(METHOD_COPY);
        methodsAllowed.append(", ").append(METHOD_PROPPATCH);

        if (m_listings) {
            methodsAllowed.append(", ").append(METHOD_PROPFIND);
        }

        if (item != null) {
            if (!item.isCollection()) {
                methodsAllowed.append(", ").append(METHOD_PUT);
            }
        }
        return methodsAllowed;
    }
53189
public function getCampaignRevenueData(
        Campaign $campaign,
        \DateTime $dateFrom,
        \DateTime $dateTo,
        $unit,
        $dbunit,
        $cache_dir = __DIR__
    ) {
        $builder = $this->getEntityManager()->getConnection()->createQueryBuilder();
        $builder
            ->select(
                'DATE_FORMAT(DATE_ADD(date_added, INTERVAL :interval SECOND), :dbUnit) as label',
                'SUM(IFNULL(cost, 0.0))                                                as cost',
                'SUM(IFNULL(revenue, 0.0))                                             as revenue',
                'SUM(IFNULL(revenue, 0.0))-SUM(IFNULL(cost, 0.0))                      as profit'
            )
            ->from('contact_ledger')
            ->where(
                $builder->expr()->eq('campaign_id', ':campaignId'),
                $builder->expr()->gte('date_added', 'FROM_UNIXTIME(:dateFrom)'),
                $builder->expr()->lte('date_added', 'FROM_UNIXTIME(:dateTo)')
            )
            ->groupBy('label');

        // query the database
        $builder->setParameter(':interval', (new \DateTime())->getOffset(), Type::INTEGER);
        $builder->setParameter(':dbUnit', $dbunit, Type::STRING);
        $builder->setParameter(':campaignId', $campaign->getId(), Type::INTEGER);
        $builder->setParameter(':dateFrom', $dateFrom->getTimestamp(), Type::INTEGER);
        $builder->setParameter(':dateTo', $dateTo->getTimestamp(), Type::INTEGER);

        $cache = new FilesystemCache($cache_dir.'/sql');

        $stmt = $builder->getConnection()->executeCacheQuery(
            $builder->getSQL(),
            $builder->getParameters(),
            $builder->getParameterTypes(),
            new QueryCacheProfile(900, 'campaign-revenue-queries', $cache)
        );

        $data = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        $stmt->closeCursor();

        // Sort and pad-out the results to match the other charts.
        $intervalMap = [
            'H' => ['hour', 'Y-m-d H:00'],
            'd' => ['day', 'Y-m-d'],
            'W' => ['week', 'Y \w\e\e\k W'],
            'Y' => ['year', 'Y'],
            'm' => ['minute', 'Y-m-d H:i'],
            's' => ['second', 'Y-m-d H:i:s'],
        ];
        $interval    = \DateInterval::createFromDateString('1 '.$intervalMap[$unit][0]);
        $periods     = new \DatePeriod($dateFrom, $interval, $dateTo);
        $updatedData = [];
        foreach ($periods as $period) {
            $dateToCheck   = $period->format($intervalMap[$unit][1]);
            $dataKey       = array_search($dateToCheck, array_column($data, 'label'));
            $updatedData[] = [
                'label'   => $dateToCheck,
                'cost'    => (false !== $dataKey) ? $data[$dataKey]['cost'] : 0,
                'revenue' => (false !== $dataKey) ? $data[$dataKey]['revenue'] : 0,
                'profit'  => (false !== $dataKey) ? $data[$dataKey]['profit'] : 0,
            ];
        }

        return $updatedData;
    }
912635
private static function restrictFeedItemToAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $feedId,
        $feedItemId,
        $adGroupId
    ) {
        $feedItemTargetService = $adWordsServices->get(
            $session,
            FeedItemTargetService::class
        );

        // Create a feed item ad group target.
        $feedItemAdGroupTarget = new FeedItemAdGroupTarget();
        $feedItemAdGroupTarget->setFeedId($feedId);
        $feedItemAdGroupTarget->setFeedItemId($feedItemId);
        $feedItemAdGroupTarget->setAdGroupId($adGroupId);

        // Create a feed item ad group target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperand($feedItemAdGroupTarget);
        $operation->setOperator(Operator::ADD);

        // Create the feed item ad group target on the server and print out
        // some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $feedItemAdGroupTarget = $result->getValue()[0];
        printf(
            'Feed item target for feed ID %d and feed item ID %d was '
            . 'created to restrict serving to ad group ID %d.%s',
            $feedItemAdGroupTarget->getFeedId(),
            $feedItemAdGroupTarget->getFeedItemId(),
            $feedItemAdGroupTarget->getAdGroupId(),
            PHP_EOL
        );
    }
632563
function permittedAttributes() {
        let filteredKeys = ghostBookshelf.Model.prototype.permittedAttributes.apply(this, arguments);

        this.relationships.forEach((key) => {
            filteredKeys.push(key);
        });

        return filteredKeys;
    }
1215250
function gatherStateMachineRestrictions (stateMachines, permissionModel) {
  // Grab restrictions from state machines
  // -------------------------------------

  const docTasks = []

  if (!stateMachines) {
    return docTasks
  }

  for (const [name, stateMachine] of Object.entries(stateMachines)) {
    for (const restriction of (stateMachine.restrictions || [])) {
      restriction.stateMachineName = name
      docTasks.push({
        domain: 'stateMachineRestriction',
        docId: name + '_' + restriction.roleId,
        docSource: restriction,
        dao: permissionModel,
        docMaker: makePermissionDoc
      })
    }
  }

  return docTasks
}
117521
public function getCampaigns() {

        return $this->createQueryBuilder('campaign')
            ->where('campaign.status != :statusBackgroundProcess')
            ->setParameter('statusBackgroundProcess', Action::STATUS_BACKGROUND_PROCESS)
            ->orderBy('campaign.startDate', 'DESC')
            ->getQuery()
            ->getResult();
    }
337229
def _filter_candidates(self, tokens, candidates):
        """"""
        results = []
        for abbr_span, long_span in candidates:
            abbr = tokens[abbr_span[0]:abbr_span[1]]
            long = tokens[long_span[0]:long_span[1]]
            if not all(a in long for a in abbr) and len(''.join(long)) > len(''.join(abbr)):
                results.append((abbr_span, long_span))
        return results
1317642
def get_all_rules(cls):
        ""
        from adblockparser import AdblockRules
        
        raw_rules = []
        for url in [
            config.ADBLOCK_EASYLIST_URL, config.ADBLOCK_EXTRALIST_URL]:
            raw_rules.extend(cls.load_raw_rules(url))

        rules = AdblockRules(raw_rules)
        return rules
1078339
def _get_candidates(self):
        
        candidates = np.where(self.dpp_vector == 0)
        return None if len(candidates[0]) == 0 else candidates[0]
682063
function getEnabledRules(allRules) {
    return Object.keys(allRules).reduce((map, id) => {
        if (allRules[id] === "error") {
            map[id] = 2
        }
        return map
    }, {})
}
1155499
def get_args(request_args, allowed_int_args=(), allowed_str_args=(), allowed_bool_args=()):
    """"""
    args = {}

    for allowed_int_arg in allowed_int_args:
        int_value = request_args.get(allowed_int_arg, default=None, type=None)

        if int_value:
            args[allowed_int_arg] = int(int_value)

    for allowed_str_arg in allowed_str_args:
        str_value = request_args.get(allowed_str_arg, default=None, type=None)

        if str_value:
            args[allowed_str_arg] = str_value

    for allowed_bool_arg in allowed_bool_args:
        str_value = request_args.get(allowed_bool_arg, default=None, type=None)

        if str_value == 'true':
            args[allowed_bool_arg] = True

        elif str_value == 'false':
            args[allowed_bool_arg] = False

    return args