Exemplo n.º 1
0
class OSCICommitsRankingAction(Action):
    """Get company amount of commits"""
    params = (
        ActionParam(name='to_day',
                    type=datetime,
                    required=True,
                    short_name='td',
                    description='till this day',
                    default=get_default_to_day()),
        ActionParam(name='date_period',
                    type=str,
                    required=False,
                    short_name='dp',
                    description='data period: day, month or year',
                    default=DatePeriodType.YTD,
                    choices=DatePeriodType.all),
        ActionParam(
            name='from_day',
            type=datetime,
            required=False,
            short_name='fd',
            description=
            f'Optional parameter will be ignored for no `DTD` time period.'),
    )

    @classmethod
    def name(cls) -> str:
        return 'osci-commits-ranking'

    def _execute(self, to_day: datetime, date_period: str, from_day: datetime):
        OSCICommitsRankingJob(date_period_type=date_period).run(
            to_date=to_day, from_date=from_day)
class ContributorsRankingMbmReportAction(Action):
    """Generate report for sending via email"""

    params = Action.params + (
        ActionParam(name='company', short_name='c', type=str, required=True),
    )

    @classmethod
    def name(cls):
        return 'get-contributors-ranking-mbm-report'

    @classmethod
    def help_text(cls) -> str:
        return "Prepared Contributors month by month report"

    def _execute(self, date: datetime, company: str):
        contributors_report = ContributorsRankingMTD(date=date, company=company)
        contributors_mbm_report = ContributorsRankingMBM(date=date, company=company)

        df = get_contributors_ranking_mbm_change_report(
            reports=contributors_report.read_all(),
            contributor_field=ContributorsRankingReportSchema.author,
            commits_amount_field=ContributorsRankingReportSchema.commits
        )
        contributors_mbm_report.save(df=df)
        return dict(out_df=str(df))
class FilterListCompanyProjectsAction(Action):
    """Filter list company projects"""

    params = Action.params + (ActionParam(
        name='company', short_name='c', type=str, required=True), )

    @classmethod
    def name(cls):
        return 'filter-list-company-projects'

    @classmethod
    def help_text(cls) -> str:
        return "Filter list company projects and save as a report"

    def _execute(self, day: datetime, company: str):
        df = ReposRankingMTD(date=day, company=company).read()
        out_df = filter_projects(
            df=df,
            projects_filter_list=DataLake().staging.load_projects_filter(),
            commits_amount_field=DataLake(
            ).public.schemas.repo_commits_ranking.commits,
            repo_name_field=DataLake(
            ).public.schemas.repo_commits_ranking.repo)
        DataLake().public.save_report(report_df=out_df,
                                      report_name='projects_activity_MTD',
                                      date=day,
                                      company=company)
Exemplo n.º 4
0
class DailyCompanyRankingsAction(Action):
    params = (
        ActionParam(name='company',
                    type=str,
                    required=True,
                    short_name='c',
                    description='Company name',
                    default=''),
        ActionParam(name='to_day',
                    type=datetime,
                    required=True,
                    short_name='td',
                    description='till this day',
                    default=get_default_to_day()),
    )

    @classmethod
    def name(cls) -> str:
        return 'daily-company-rankings'

    def _execute(self, company: str, to_day: datetime):
        for date_period in [DatePeriodType.YTD, DatePeriodType.MTD]:
            company_contributors_ranking_job = ContributorsRankingJob(
                date_period_type=date_period, company=company)
            company_contributors_repos_ranking_job = ContributorsReposRankingJob(
                date_period_type=date_period, company=company)
            company_repos_ranking_job = ReposRankingJob(
                date_period_type=date_period, company=company)

            commits = company_contributors_ranking_job.extract(
                to_date=to_day).cache()

            company_contributors_ranking_job.load(
                df=company_contributors_ranking_job.transform(commits),
                date=to_day)
            company_contributors_repos_ranking_job.load(
                df=company_contributors_repos_ranking_job.transform(commits),
                date=to_day)
            company_repos_ranking_job.load(
                df=company_repos_ranking_job.transform(commits), date=to_day)

        company_month_by_month_commits_amount_job = MonthByMonthCommitsJob(
            date_period_type=DatePeriodType.YTD, company=company)
        company_month_by_month_commits_amount_job.load(
            df=company_month_by_month_commits_amount_job.transform(commits),
            date=to_day)
Exemplo n.º 5
0
class LoadPushEventTOBQAction(Action):
    params = Action.params + (ActionParam(
        name='hour', short_name='h', type=int, required=False, default='0'), )

    @classmethod
    def name(cls) -> str:
        return "load-push-events-to-bq"

    def _execute(self, day: datetime.datetime,
                 hour: int) -> Dict[str, Dict[str, Any]]:
        return load_push_events_to_bq(day, hour)
Exemplo n.º 6
0
class CompanyContributorsReposRankingAction(Action):
    """Count employees repos commits"""
    params = (
        ActionParam(name='company',
                    type=str,
                    required=True,
                    short_name='c',
                    description='Company name',
                    default=''),
        ActionParam(name='to_day',
                    type=datetime,
                    required=True,
                    short_name='td',
                    description='till this day',
                    default=get_default_to_day()),
        ActionParam(name='date_period',
                    type=str,
                    required=False,
                    short_name='dp',
                    description='data period: day, month or year',
                    default=DatePeriodType.YTD,
                    choices=DatePeriodType.all),
        ActionParam(
            name='from_day',
            type=datetime,
            required=False,
            short_name='fd',
            description=
            f'Optional parameter will be ignored for no `DTD` time period.',
            default=get_default_from_day()),
    )

    @classmethod
    def name(cls) -> str:
        return 'company-contributors-repos-ranking'

    def _execute(self, company: str, to_day: datetime, date_period: str,
                 from_day: datetime):
        ContributorsReposRankingJob(date_period_type=date_period,
                                    company=company).run(to_date=to_day,
                                                         from_date=from_day)
Exemplo n.º 7
0
class LoadOSCIRankingToBQAction(Action):
    params = Action.params + (
        ActionParam(name='date_period', type=str, required=False,
                    short_name='dp', description='data period: day, month or year',
                    default=DatePeriodType.YTD, choices=DatePeriodType.all),
    )

    @classmethod
    def name(cls) -> str:
        return "load-osci-ranking-to-big-query"

    def _execute(self, day: datetime.datetime, date_period: str) -> Dict[str, Dict[str, Any]]:
        table = load_osci_ranking_to_bq(date=day, date_period=date_period)
        return {'table': {'id': table.table_id, 'rows': table.num_rows}}
class DailyOSCIRankingsAction(Action):
    """Daily Main ETL"""
    params = (ActionParam(name='to_day',
                          type=datetime,
                          required=True,
                          short_name='td'), )

    @classmethod
    def help_text(cls) -> str:
        return "Transform, filter and save data for the subsequent creating report"

    @classmethod
    def name(cls):
        return 'daily-osci-rankings'

    def _execute(self, to_day: datetime):
        for date_period in [DatePeriodType.YTD, DatePeriodType.MTD]:
            osci_ranking_job = OSCIRankingJob(date_period_type=date_period)
            osci_commits_ranking_job = OSCICommitsRankingJob(
                date_period_type=date_period)

            commits = osci_ranking_job.extract(to_date=to_day).cache()

            osci_ranking_job.load(df=osci_ranking_job.transform(commits),
                                  date=to_day)
            osci_commits_ranking_job.load(
                df=osci_commits_ranking_job.transform(commits), date=to_day)

            if date_period == DatePeriodType.YTD:
                company_contributors_repos = CompanyContributorsRepositoryCommitsJob(
                    date_period_type=date_period)
                company_contributors_repos.load(
                    company_contributors_repos.transform(commits, date=to_day),
                    date=to_day)

                osci_contributors_ranking_job = OSCIContributorsRankingJob(
                    date_period_type=date_period)
                osci_contributors_ranking_job.load(
                    osci_contributors_ranking_job.transform(commits),
                    date=to_day)
                osci_language_job = OSCILanguagesJob(
                    date_period_type=date_period)
                osci_language_job.load(osci_language_job.transform(commits),
                                       date=to_day)

                osci_licenses_ytd = OSCILicensesJob(
                    date_period_type=date_period)
                osci_licenses_ytd.load(osci_licenses_ytd.transform(df=commits),
                                       date=to_day)
class FindContributorsRepositoriesChangeAction(Action):
    """Load company commits for the day"""

    params = Action.params + (ActionParam(name='company',
                                          type=str,
                                          required=True,
                                          short_name='c',
                                          description='Company name'), )

    @classmethod
    def name(cls) -> str:
        return 'find-contributors-repositories-change'

    def _execute(self, day: datetime, company: str):
        return get_contributors_repositories_change(date=day, company=company)
Exemplo n.º 10
0
class OSCILicensesAction(Action):
    """Generates OSCI commits enriched with licenses"""
    params = (ActionParam(name='to_day',
                          type=datetime,
                          required=True,
                          short_name='td',
                          description='till this day'), )

    @classmethod
    def name(cls) -> str:
        return 'osci-licenses'

    def _execute(self, to_day: datetime):
        OSCILicensesJob(date_period_type=DatePeriodType.YTD).run(
            to_date=to_day)
Exemplo n.º 11
0
class OSCIContributorsRankingAction(Action):
    """Generates OSCI contributors ranking"""
    params = (ActionParam(name='to_day',
                          type=datetime,
                          required=True,
                          short_name='td',
                          description='till this day'), )

    @classmethod
    def name(cls) -> str:
        return 'osci-contributors-ranking'

    def _execute(self, to_day: datetime):
        OSCIContributorsRankingJob(date_period_type=DatePeriodType.YTD).run(
            to_date=to_day)
Exemplo n.º 12
0
class CompanyMonthByMonthCommitsAmountAction(Action):
    """Get month-by-month amount of commits"""
    params = (
        ActionParam(name='company',
                    type=str,
                    required=True,
                    short_name='c',
                    description='Company name',
                    default=''),
        ActionParam(name='to_day',
                    type=datetime,
                    required=True,
                    short_name='td',
                    description='till this day',
                    default=get_default_to_day()),
    )

    @classmethod
    def name(cls) -> str:
        return 'company-month-by-month-commits-amount'

    def _execute(self, company: str, to_day: datetime):
        MonthByMonthCommitsJob(date_period_type=DatePeriodType.YTD,
                               company=company).run(to_date=to_day)
Exemplo n.º 13
0
class LoadCompanyCommitsAction(Action):
    """Load company commits for the day"""

    params = Action.params + (ActionParam(name='company',
                                          short_name='c',
                                          type=str,
                                          required=True,
                                          description='Company name'), )

    @classmethod
    def name(cls) -> str:
        return 'load-company-commits'

    @classmethod
    def help_text(cls) -> str:
        return "Load company repositories events commits"

    def _execute(self, day: datetime, company: str):
        return load_company_repositories_events_commits(date=day,
                                                        company=company)