Get all issues for a specific job.
320162
def get_issues_by_resource(resource_id, table):
    """"""

    v1_utils.verify_existence_and_get(resource_id, table)

    # When retrieving the issues for a job, we actually retrieve
    # the issues attach to the job itself + the issues attached to
    # the components the job has been run with.
    if table.name == 'jobs':
        JJI = models.JOIN_JOBS_ISSUES
        JJC = models.JOIN_JOBS_COMPONENTS
        JCI = models.JOIN_COMPONENTS_ISSUES

        # Get all the issues attach to all the components attach to a job
        j1 = sql.join(
            _TABLE,
            sql.join(
                JCI,
                JJC,
                sql.and_(
                    JCI.c.component_id == JJC.c.component_id,
                    JJC.c.job_id == resource_id,
                ),
            ),
            _TABLE.c.id == JCI.c.issue_id,
        )

        query = sql.select([_TABLE]).select_from(j1)
        rows = flask.g.db_conn.execute(query)
        rows = [dict(row) for row in rows]

        # Get all the issues attach to a job
        j2 = sql.join(
            _TABLE,
            JJI,
            sql.and_(
                _TABLE.c.id == JJI.c.issue_id,
                JJI.c.job_id == resource_id
            )
        )
        query2 = sql.select([_TABLE]).select_from(j2)
        rows2 = flask.g.db_conn.execute(query2)
        rows += [dict(row) for row in rows2]

    # When retrieving the issues for a component, we only retrieve the
    # issues attached to the specified component.
    else:
        JCI = models.JOIN_COMPONENTS_ISSUES

        query = (sql.select([_TABLE])
                 .select_from(JCI.join(_TABLE))
                 .where(JCI.c.component_id == resource_id))

        rows = flask.g.db_conn.execute(query)
        rows = [dict(row) for row in rows]

    for row in rows:
        if row['tracker'] == 'github':
            l_tracker = github.Github(row['url'])
        elif row['tracker'] == 'bugzilla':
            l_tracker = bugzilla.Bugzilla(row['url'])
        row.update(l_tracker.dump())

    return flask.jsonify({'issues': rows,
                          '_meta': {'count': len(rows)}})
492203
def get_jobs(self, job_ids = None):
    """"""
    if job_ids is not None and len(job_ids) == 0:
      return []
    q = self.session.query(Job)
    if job_ids is not None:
      q = q.filter(Job.unique.in_(job_ids))
    return sorted(list(q), key=lambda job: job.unique)
134647
def attach_issue(resource_id, table, user_id):
    """"""
    data = schemas.issue.post(flask.request.json)
    issue = _get_or_create_issue(data)

    # Second, insert a join record in the JOIN_JOBS_ISSUES or
    # JOIN_COMPONENTS_ISSUES database.
    if table.name == 'jobs':
        join_table = models.JOIN_JOBS_ISSUES
    else:
        join_table = models.JOIN_COMPONENTS_ISSUES

    key = '%s_id' % table.name[0:-1]
    query = join_table.insert().values({
        'user_id': user_id,
        'issue_id': issue['id'],
        key: resource_id
    })

    try:
        flask.g.db_conn.execute(query)
    except sa_exc.IntegrityError:
        raise dci_exc.DCICreationConflict(join_table.name,
                                          '%s, issue_id' % key)

    result = json.dumps({'issue': dict(issue)})
    return flask.Response(result, 201, content_type='application/json')
693258
def get_task(self, key):
        """"""
        res, pk = key
        jobs, lock = self._jobs
        with lock:
            return jobs[res].get(pk)
129944
def fetch_job_messages(offset, job_id, opts = {})
      data, _status_code, _headers = fetch_job_messages_with_http_info(offset, job_id, opts)
      return data
    end
441346
def all_jobs(self):
        
        from db.models.jobs import Job

        return Job.all.filter(project=self)
1089747
def attach_issue(context, id, url):
    

    result = job.attach_issue(context, id=id, url=url)
    utils.format_output(result, context.format)
410641
def worklogs(self, issue):
        
        r_json = self._get_json('issue/' + str(issue) + '/worklog')
        worklogs = [Worklog(self._options, self._session, raw_worklog_json)
                    for raw_worklog_json in r_json['worklogs']]
        return worklogs
978560
def all(self, data={}, **kwargs):
        "
        return super(Invoice, self).all(data, **kwargs)
1131821
def format_issues(issues)
      results = [t('myissues.info')]
      results.concat(issues.map { |issue| format_issue(issue) })
    end
467826
def get_output_content(job_id, max_size=1024, conn=None):
    
    content = None
    if RBO.index_list().contains(IDX_OUTPUT_JOB_ID).run(conn):
        # NEW
        check_status = RBO.get_all(job_id, index=IDX_OUTPUT_JOB_ID).run(conn)
    else:
        # OLD
        check_status = RBO.filter({OUTPUTJOB_FIELD: {ID_FIELD: job_id}}).run(conn)
    for status_item in check_status:
        content = _truncate_output_content_if_required(status_item, max_size)
    return content
1064387
def _all(self, query):
        """"""
        if query.count() > 0:
            results = query.all()
            for result in results:
                if result.has_expired(self._expirations):
                    raise NotFoundError
            return results
        else:
            raise NotFoundError
394812
def relevent_issue(issue, after):
    """"""
    return (closed_issue(issue, after) and
            issue_completed(issue) and
            issue_section(issue))
715107
def resultsFor( self, ps ):
        """"""
        k = self._parametersAsIndex(ps)
        if k in self._results.keys():
            # filter out pending job ids, which can be anything except dicts
            return [ res for res in self._results[k] if isinstance(res, dict) ]
        else:
            return []
1224750
def fetch_closed_issues_and_pr
      print "Fetching closed issues...\r" if @options[:verbose]
      issues = []
      page_i      = 0
      count_pages = calculate_pages(@client, "issues", closed_pr_options)

      iterate_pages(@client, "issues", closed_pr_options) do |new_issues|
        page_i += PER_PAGE_NUMBER
        print_in_same_line("Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
        issues.concat(new_issues)
        break if @options[:max_issues] && issues.length >= @options[:max_issues]
      end
      print_empty_line
      Helper.log.info "Received issues: #{issues.count}"

      # separate arrays of issues and pull requests:
      issues.map { |issue| stringify_keys_deep(issue.to_hash) }
            .partition { |issue_or_pr| issue_or_pr["pull_request"].nil? }
    end
113563
def query_all_issues(after):
    """"""
    page = count(1)
    data = []
    while True:
        page_data = query_issues(next(page), after)
        if not page_data:
            break
        data.extend(page_data)
    return data
379052
def parse_job_files(self):
        """"""
        repo_jobs = []
        for rel_job_file_path, job_info in self.job_files.items():
            LOGGER.debug("Checking for job definitions in %s", rel_job_file_path)
            jobs = self.parse_job_definitions(rel_job_file_path, job_info)
            LOGGER.debug("Found %d job definitions in %s", len(jobs), rel_job_file_path)
            repo_jobs.extend(jobs)
        if not repo_jobs:
            LOGGER.info("No job definitions found in repo '%s'", self.repo)
        else:
            LOGGER.info(
                "Found %d job definitions in repo '%s'", len(repo_jobs), self.repo
            )
            # LOGGER.debug(json.dumps(repo_jobs, indent=4))
        return repo_jobs