Generate the data for the Activity section in the report
        :return:
971221
def sec_project_activity(self, project=None):
        

        def create_data(metrics, project):
            csv_labels = "labels" + ',' + metrics[0].id + "," + metrics[1].id
            file_label = metrics[0].ds.name + "_" + metrics[0].id + "_"
            file_label += metrics[1].ds.name + "_" + metrics[1].id
            title_label = metrics[0].name + ", " + metrics[1].name + " per " + self.interval
            self.__create_csv_eps(metrics[0], metrics[1], csv_labels,
                                  file_label, title_label, project)

        logger.info("Activity data for: %s", project)

        for activity_ds in self.config['project_activity']:
            if activity_ds == 'metrics':
                continue  # all metrics included
            metrics = self.config['project_activity'][activity_ds]
            create_data(metrics, project)
208375
public Reportable generateReports() {
        Trends trends = null;

        try {
            // first copy static resources so ErrorPage is displayed properly
            copyStaticResources();

            // create directory for embeddings before files are generated
            createEmbeddingsDirectory();

            // add metadata info sourced from files
            reportParser.parseClassificationsFiles(configuration.getClassificationFiles());

            // parse json files for results
            List<Feature> features = reportParser.parseJsonFiles(jsonFiles);
            reportResult = new ReportResult(features, configuration);
            Reportable reportable = reportResult.getFeatureReport();

            if (configuration.isTrendsAvailable()) {
                // prepare data required by generators, collect generators and generate pages
                trends = updateAndSaveTrends(reportable);
            }

            // Collect and generate pages in a single pass
            generatePages(trends);

            return reportable;

            // whatever happens we want to provide at least error page instead of incomplete report or exception
        } catch (Exception e) {
            generateErrorPage(e);
            // update trends so there is information in history that the build failed

            // if trends was not created then something went wrong
            // and information about build failure should be saved
            if (!wasTrendsFileSaved && configuration.isTrendsAvailable()) {
                Reportable reportable = new EmptyReportable();
                updateAndSaveTrends(reportable);
            }

            // something went wrong, don't pass result that might be incomplete
            return null;
        }
    }
147142
def get_report_data(self, report):
        
        ar = report.getAnalysisRequest()
        attachments = map(self.get_attachment_data, ar.getAttachment())
        pdf = self.get_pdf(report)
        filesize = "{} Kb".format(self.get_filesize(pdf))
        filename = "{}.pdf".format(ar.getId())

        return {
            "ar": ar,
            "attachments": attachments,
            "pdf": pdf,
            "obj": report,
            "uid": api.get_uid(report),
            "filesize": filesize,
            "filename": filename,
        }
877526
def report(self):
        
        # Add all the genes to the header
        header = 'Sample,'
        data = str()
        with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
            write_header = True
            for sample in self.runmetadata:
                data += sample.name + ','
                # Iterate through all the user-supplied target names
                for target in sorted(self.genes):
                    write_results = False
                    # There was an issue with 'target' not matching 'name' due to a dash being replaced by an underscore
                    # only in 'name'. This will hopefully address this issue
                    target = target.replace('-', '_')
                    if write_header:
                        header += '{target}_match_details,{target},'.format(target=target)
                    for name, identity in sample[self.analysistype].results.items():
                        # Ensure that all dashes are replaced with underscores
                        name = name.replace('-', '_')
                        # If the current target matches the target in the header, add the data to the string
                        if name == target:
                            write_results = True
                            gene_results = '{percent_id}% ({avgdepth} +/- {stddev}),{record},'\
                                .format(percent_id=identity,
                                        avgdepth=sample[self.analysistype].avgdepth[name],
                                        stddev=sample[self.analysistype].standarddev[name],
                                        record=sample[self.analysistype].sequences[target])
                            # Populate the data string appropriately
                            data += gene_results
                    # If the target is not present, write dashes to represent the results and sequence
                    if not write_results:
                        data += '-,-,'
                data += ' \n'
                write_header = False
            header += '\n'
            # Write the strings to the report
            report.write(header)
            report.write(data)
303757
public function get_activities_and_headings() {
        global $OUTPUT;
        $moduleinfo = get_fast_modinfo($this->courseid);
        $sections = $moduleinfo->get_sections();
        $data = new stdClass;
        $data->courseid = $this->courseid;
        $data->sesskey = sesskey();
        $data->helpicon = $OUTPUT->help_icon('bulkcompletiontracking', 'core_completion');
        $data->sections = [];
        foreach ($sections as $sectionnumber => $section) {
            $sectioninfo = $moduleinfo->get_section_info($sectionnumber);

            $sectionobject = new stdClass();
            $sectionobject->sectionnumber = $sectionnumber;
            $sectionobject->name = get_section_name($this->courseid, $sectioninfo);
            $sectionobject->activities = $this->get_activities($section, true);
            $data->sections[] = $sectionobject;
        }
        return $data;
    }
924964
def activities(self):
        
        if self._activities is None:
            self.assert_bind_client()
            self._activities = self.bind_client.get_club_activities(self.id)
        return self._activities
1257899
def get_main_activity(self):
        
        activities = self.get_main_activities()
        if len(activities) > 0:
            return self._format_value(activities.pop())
        return None
1186802
def get_section_metrics(cls):
        

        return {
            "overview": {
                "activity_metrics": [Commits],
                "author_metrics": [Authors],
                "bmi_metrics": [],
                "time_to_close_metrics": [],
                "projects_metrics": [Projects]
            },
            "com_channels": {
                "activity_metrics": [],
                "author_metrics": []
            },
            "project_activity": {
                # TODO: Authors is not activity but we need two metrics here
                "metrics": [Commits, Authors]
            },
            "project_community": {
                "author_metrics": [Authors],
                "people_top_metrics": [Authors],
                "orgs_top_metrics": [Organizations],
            },
            "project_process": {
                "bmi_metrics": [],
                "time_to_close_metrics": [],
                "time_to_close_title": "",
                "time_to_close_review_metrics": [],
                "time_to_close_review_title": "",
                "patchsets_metrics": []
            }
        }
790028
public function assessmentActivity()
    {
        $service = $this->getServiceLocator()->get(ActivityMonitoringService::SERVICE_ID);

        // Reason categories
        $this->setData('reason_categories', DeliveryHelper::getAllReasonsCategories());

        // Config
        $config = [ActivityMonitoringService::OPTION_USER_ACTIVITY_WIDGETS =>
            $service->getOption(ActivityMonitoringService::OPTION_USER_ACTIVITY_WIDGETS),
            ActivityMonitoringService::OPTION_ASSESSMENT_ACTIVITY_AUTO_REFRESH =>
                $service->getOption(ActivityMonitoringService::OPTION_ASSESSMENT_ACTIVITY_AUTO_REFRESH),
            ActivityMonitoringService::OPTION_COMPLETED_ASSESSMENTS_AUTO_REFRESH =>
                $service->getOption(ActivityMonitoringService::OPTION_COMPLETED_ASSESSMENTS_AUTO_REFRESH),
        ];
        $this->setData('config', $config);

        $this->setView('Tools/assessment_activity.tpl');
    }
511187
def gather_explicit_activities(self):
        
        for stmt in self.statements:
            agents = stmt.agent_list()
            # Activity types given as ActivityConditions
            for agent in agents:
                if agent is not None and agent.activity is not None:
                    agent_base = self._get_base(agent)
                    agent_base.add_activity(agent.activity.activity_type)
            # Object activities given in RegulateActivity statements
            if isinstance(stmt, RegulateActivity):
                if stmt.obj is not None:
                    obj_base = self._get_base(stmt.obj)
                    obj_base.add_activity(stmt.obj_activity)
            # Activity types given in ActiveForms
            elif isinstance(stmt, ActiveForm):
                agent_base = self._get_base(stmt.agent)
                agent_base.add_activity(stmt.activity)
                if stmt.is_active:
                    agent_base.add_active_state(stmt.activity, stmt.agent,
                                                stmt.evidence)
                else:
                    agent_base.add_inactive_state(stmt.activity, stmt.agent,
                                                  stmt.evidence)
1299051
def reporter(self):
        
        # Create the path in which the reports are stored
        make_path(self.reportpath)
        header = 'Strain,Gene,PercentIdentity,Genus,FoldCoverage\n'
        data = ''
        with open(os.path.join(self.reportpath, self.analysistype + '.csv'), 'w') as report:
            for sample in self.runmetadata.samples:
                data += sample.name + ','
                if sample[self.analysistype].results:
                    if not sample[self.analysistype].multiple:
                        for name, identity in sample[self.analysistype].results.items():
                            if name == sample[self.analysistype].besthit[0]:
                                data += '{},{},{},{}\n'.format(name, identity, sample[self.analysistype].genera[name],
                                                               sample[self.analysistype].avgdepth[name])
                    else:
                        data += '{},{},{},{}\n'.format('multiple', 'NA', ';'.join(sample[self.analysistype]
                                                                                  .classification), 'NA')
                else:
                    data += '\n'
            report.write(header)
            report.write(data)
1362953
def get_usage(self):
        """"""

        resp = requests.get(FITNESS_URL, timeout=30)
        resp.raise_for_status()

        soup = BeautifulSoup(resp.text, "html5lib")
        eastern = pytz.timezone('US/Eastern')
        output = []
        for item in soup.findAll("div", {"class": "barChart"}):
            data = [x.strip() for x in item.get_text("\n").strip().split("\n")]
            data = [x for x in data if x]
            name = re.sub(r"\s*(Hours)?\s*-?\s*(CLOSED|OPEN)?$", "", data[0], re.I).strip()
            output.append({
                "name": name,
                "open": "Open" in data[1],
                "count": int(data[2].rsplit(" ", 1)[-1]),
                "updated": eastern.localize(datetime.datetime.strptime(data[3][8:].strip(), '%m/%d/%Y %I:%M %p')).isoformat(),
                "percent": int(data[4][:-1])
            })
        return output
242412
def get_context_data(self, **kwargs):
        """"""
        context = super(ReportMixin, self).get_context_data(**kwargs)

        form = self.get_form()
        if form.is_valid():
            data = form.cleaned_data
            start, end = form.save()
            entryQ = self.get_entry_query(start, end, data)
            trunc = data['trunc']
            if entryQ:
                vals = ('pk', 'activity', 'project', 'project__name',
                        'project__status', 'project__type__label')
                entries = Entry.objects.date_trunc(
                    trunc, extra_values=vals).filter(entryQ)
            else:
                entries = Entry.objects.none()

            end = end - relativedelta(days=1)
            date_headers = generate_dates(start, end, by=trunc)
            context.update({
                'from_date': start,
                'to_date': end,
                'date_headers': date_headers,
                'entries': entries,
                'filter_form': form,
                'trunc': trunc,
            })
        else:
            context.update({
                'from_date': None,
                'to_date': None,
                'date_headers': [],
                'entries': Entry.objects.none(),
                'filter_form': form,
                'trunc': '',
            })

        return context
1282320
def get_sec_project_activity(self):
        

        logger.debug("Calculating Project Activity metrics.")

        data_path = os.path.join(self.data_dir, "activity")
        if not os.path.exists(data_path):
            os.makedirs(data_path)

        for ds in self.data_sources:
            metric_file = self.ds2class[ds]
            metric_index = self.get_metric_index(ds)
            project_activity = metric_file.project_activity(metric_index, self.start_date,
                                                            self.end_date)
            headers = []
            data_frames = []
            title_names = []
            file_name = ""
            for metric in project_activity['metrics']:
                file_name += metric.DS_NAME + "_" + metric.id + "_"
                title_names.append(metric.name)
                headers.append(metric.id)
                data_frames.append(metric.timeseries(dataframe=True))

            file_name = file_name[:-1]  # remove trailing underscore
            file_path = os.path.join(data_path, file_name)
            title_name = " & ".join(title_names) + ' per ' + self.interval
            self.create_csv_fig_from_df(data_frames, file_path, headers,
                                        fig_type="bar", title=title_name)
919838
def generate_sections(self):
        """"""
        sources = Dataset.objects.values(
            'source', 'source_slug'
        ).annotate(source_count=Count('source_slug'))

        return sorted([
            {
                'slug': source['source_slug'],
                'name': source['source'],
                'count': source['source_count']
            }
            for source in sources
        ], key=lambda k: k['count'], reverse=True)
702187
def report_progress(self):
        """"""
        percent = self.calc_percent()
        total = format_bytes(self._total)

        speed = self.calc_speed()
        total_speed_report = '{0} at {1}'.format(total, speed)

        report = '\r{0: <56} {1: >30}'.format(percent, total_speed_report)

        if self._finished:
            print(report)
        else:
            print(report, end="")
        sys.stdout.flush()
323276
def generate_count_report!
      report = count_queries.inject({}) do |report_hash, (k, v)|
        report_hash[k] = solutions_to_counts(v.execute)
        report_hash
      end

      update(count_report: report)
    end