Calculate percentage of successfully deployed components

@param collectorItemId Collector Item Id of deploy
@return percentage of deployed components
764749
private Double fetchDeploySuccessRatio(ObjectId collectorItemId) {
    int totalDeploys = 0, totalDeploySuccess = 0;
    Double deploySuccessScore = null;

    List<EnvironmentComponent> components = environmentComponentRepository
      .findByCollectorItemId(collectorItemId);

    if (null == components || components.isEmpty()) {
      return null;
    }

    for (EnvironmentComponent environmentComponent : components) {
      totalDeploys++;
      if (environmentComponent.isDeployed()) {
        totalDeploySuccess++;
      }
    }
    deploySuccessScore = ((totalDeploySuccess * 100) / (double) totalDeploys);
    LOGGER.info("totalDeploys " + totalDeploys + " totalDeploySuccess " + totalDeploySuccess + " deploySuccessScore " + deploySuccessScore);

    return deploySuccessScore;
  }
408083
public function getSumOfShippedItemsByItemId($itemId, $includeStatusDeliveryNote)
    {
        try {
            $qb = $this->createQueryBuilder('shipping')
                ->select('sum(shippingItems.quantity) AS shipped')
                ->join('shipping.shippingItems', 'shippingItems')
                ->join('shippingItems.item', 'item', 'WITH', 'item.id = :itemId')
                ->join('shipping.status', 'status')
                ->groupBy('item.id')
                ->where('status.id = :statusId')
                ->setParameter('itemId', $itemId)
                ->setParameter('statusId', ShippingStatus::STATUS_SHIPPED);
            if ($includeStatusDeliveryNote) {
                $qb->orWhere('status.id = :statusId2')
                    ->setParameter('statusId2', ShippingStatus::STATUS_DELIVERY_NOTE);
            }
            return $qb->getQuery()->getSingleScalarResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
656975
@Override
	public Page<Scope> getScopeByCollectorWithFilter(ObjectId collectorId, String projectName, Pageable pageable){

		Page<Scope> scopeItems =  scopeRepository.findAllByCollectorIdAndNameContainingIgnoreCase(collectorId,projectName,pageable);
		return scopeItems;
	}
1363455
@Override
  protected final MtasDataItemLongAdvanced getItem(int i) {
    if (i >= 0 && i < size) {
      return new MtasDataItemLongAdvanced(advancedValueSumList[i],
          advancedValueSumOfLogsList[i], advancedValueSumOfSquaresList[i],
          advancedValueMinList[i], advancedValueMaxList[i],
          advancedValueNList[i], hasSub() ? subCollectorListNextLevel[i] : null,
          getStatsItems(), sortType, sortDirection, errorNumber[i],
          errorList[i], sourceNumberList[i]);
    } else {
      return null;
    }
  }
805033
private static void collectUidStats(final UniqueId uid,
                                      final StatsCollector collector) {
    collector.record("uid.cache-hit", uid.cacheHits(), "kind=" + uid.kind());
    collector.record("uid.cache-miss", uid.cacheMisses(), "kind=" + uid.kind());
    collector.record("uid.cache-size", uid.cacheSize(), "kind=" + uid.kind());
    collector.record("uid.random-collisions", uid.randomIdCollisions(),
        "kind=" + uid.kind());
    collector.record("uid.rejected-assignments", uid.rejectedAssignments(),
        "kind=" + uid.kind());
  }
1333374
public static function find_ltiservice_gradebookservice_for_lineitem($lineitemid) {
        global $DB;

        if (!$lineitemid) {
            return false;
        }
        $gradeitem = $DB->get_record('grade_items', array('id' => $lineitemid));
        if ($gradeitem) {
            $gbs = $DB->get_record('ltiservice_gradebookservices',
                    array('gradeitemid' => $gradeitem->id, 'courseid' => $gradeitem->courseid));
            if ($gbs) {
                return $gbs;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
584049
public function moveCollectionThumbnail($collectionId, $itemId, $position, $accessToken)
    {
        if (!$this->apiVersionIsGreaterThanV3()) {
            throw new EndpointNotSupportedByApiVersionException();
        }

        if (!is_string($itemId)) {
            throw new InvalidTypeException('Item ID', 'string', gettype($itemId));
        }

        if ($position < 1) {
            throw new TwitchApiException('Collection position cannot be less than 1.');
        }

        $params = [
            'position' => $position,
        ];

        return $this->put(sprintf('collections/%s/itmes/%s', $collectionId, $itemId), $params, $accessToken);
    }
878443
public synchronized int getPartitionStoreMoves() {
        int count = 0;
        for (List<Integer> entry : storeToPartitionIds.values())
            count += entry.size();
        return count;
    }
230127
def transferring_item(self, item, increment_amt=1):
        
        self.cnt += increment_amt
        percent_done = int(float(self.cnt) / float(self.total) * 100.0)
        if KindType.is_project(item):
            details = 'project'
        else:
            details = os.path.basename(item.path)
        self.progress_bar.update(percent_done, '{} {}'.format(self.msg_verb, details))
        self.progress_bar.show()
954425
public static <T> Collector<T, ?, Optional<T>> median(Comparator<? super T> comparator) {
        return percentile(0.5, comparator);
    }
724147
public List<String> getContainedItemId() {
        if (StringUtils.isBlank(_contains))
            return Collections.emptyList();
        return Arrays.asList(StringUtils.split(_contains, ','));
    }
121374
@Override public int getItemCount() {
    int size = items.size();
    if (hasHeader()) {
      size++;
    }
    if (hasFooter()) {
      size++;
    }
    return size;
  }
851958
public static int countItems(final IItemAdapter adapter, boolean countHeaders) {
        return countItems(adapter.getAdapterItems(), countHeaders, false, null);
    }
174477
def _request_status(self):
        
        if self.item_id:
            return True

        response = self.con.get(self.monitor_url)
        if not response:
            return False

        data = response.json()

        self.status = data.get('status', 'inProgress')
        self.completion_percentage = data.get(self._cc('percentageComplete'),
                                              0)
        self.item_id = data.get(self._cc('resourceId'), None)

        return self.item_id is not None
76128
private void handleCollectorItems(List<Component> components) {
        for (Component component : components) {
            Map<CollectorType, List<CollectorItem>> itemMap = component.getCollectorItems();
            for (CollectorType type : itemMap.keySet()) {
                List<CollectorItem> items = itemMap.get(type);
                for (CollectorItem i : items) {
                    if (CollectionUtils.isEmpty(customRepositoryQuery.findComponents(i.getCollectorId(),type,i))) {
                        i.setEnabled(false);
                        collectorItemRepository.save(i);
                    }
                }
            }
        }
    }
881082
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts") // agreed, fixme
    private void clean(Collector collector) {
        Set<ObjectId> uniqueIDs = new HashSet<>();
        /*
          Logic: For each component, retrieve the collector item list of the type SCM.
          Store their IDs in a unique set ONLY if their collector IDs match with GitHub collectors ID.
         */
        for (com.capitalone.dashboard.model.Component comp : dbComponentRepository.findAll()) {
            if (!MapUtils.isEmpty(comp.getCollectorItems())) {
                List<CollectorItem> itemList = comp.getCollectorItems().get(CollectorType.SCM);
                if (itemList != null) {
                    itemList.stream().filter(ci -> ci != null && Objects.equals(ci.getCollectorId(), collector.getId())).map(BaseModel::getId).forEach(uniqueIDs::add);
                }
            }
        }
        /*
          Logic: Get all the collector items from the collector_item collection for this collector.
          If their id is in the unique set (above), keep them enabled; else, disable them.
         */
        List<GitHubRepo> repoList = new ArrayList<>();
        Set<ObjectId> gitID = new HashSet<>();
        gitID.add(collector.getId());
        gitHubRepoRepository.findByCollectorIdIn(gitID).stream().filter(Objects::nonNull).forEach(repo -> {
            if (repo.isPushed()) {return;}
            repo.setEnabled(uniqueIDs.contains(repo.getId()));
            repoList.add(repo);
        });
        gitHubRepoRepository.save(repoList);
    }
130992
protected void invokeCollectorIfPresent() {
		if (collectorProxy != null) {
			Serializable data = collectorProxy.collectPartitionData();
			logger.finer("Got partition data: " + data + ", from collector: " + collectorProxy);
			sendCollectorDataPartitionReplyMsg(data);
		} 
	}