Skip to content

Commit

Permalink
Restructure to keep the sync importer indeed minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
matejak committed May 30, 2024
1 parent d13b17b commit fa459d6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
7 changes: 7 additions & 0 deletions estimage/plugins/jira/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ def get_task_events(self, importer=None):


class Importer(importer.BareboneImporter):
def __init__(self, spec):
super().__init__(spec)

self.retrospective_query = spec.retrospective_query
self.projective_query = spec.projective_query
self.cutoff_date = spec.cutoff_date

def _execute_search_query(self, query):
items = self.jira.search_issues(query, expand="changelog,renderedFields", maxResults=0)
return items
Expand Down
3 changes: 0 additions & 3 deletions estimage/plugins/jira/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ def __init__(self, spec):
raise RuntimeError(msg) from exc

self.item_class = spec.item_class
self.retrospective_query = spec.retrospective_query
self.projective_query = spec.projective_query
self.cutoff_date = spec.cutoff_date

def report(self, msg):
print(msg)
Expand Down
37 changes: 20 additions & 17 deletions estimage/plugins/redhat_jira/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ def from_form_and_app(cls, input_form, app) -> "InputSpec":
return ret


class Importer(jira.Importer):
class SyncImporter(jira.importer.BareboneImporter):
STORY_POINTS = "customfield_12310243"
EPIC_LINK = "customfield_12311140"
CONTRIBUTORS = "customfield_12315950"
WORK_START = "customfield_12313941"
WORK_END = "customfield_12313942"

def _get_points_of(self, item):
ret = self._get_contents_of_field(item, self.STORY_POINTS, 0)
Expand All @@ -87,6 +83,24 @@ def _get_points_of(self, item):
def _set_points_of(self, item, points):
item.update({self.STORY_POINTS: round(points, 2)})

def get_points_of(self, our_task):
jira_task = self.find_card(our_task.name)
remote_points = self._get_points_of(jira_task)
return remote_points

def update_points_of(self, our_task, points):
jira_task = self.find_card(our_task.name)
self._set_points_of(jira_task, points)
our_task.point_cost = points
return our_task


class Importer(jira.Importer, SyncImporter):
EPIC_LINK = "customfield_12311140"
CONTRIBUTORS = "customfield_12315950"
WORK_START = "customfield_12313941"
WORK_END = "customfield_12313942"

@classmethod
def _status_to_state(cls, item, jira_string):
if cls._item_is_closed_done(item, jira_string):
Expand Down Expand Up @@ -133,17 +147,6 @@ def _record_work_span(self, result, item):
if work_span[0] or work_span[-1]:
result.work_span = tuple(work_span)

def get_points_of(self, our_task):
jira_task = self.find_card(our_task.name)
remote_points = self._get_points_of(jira_task)
return remote_points

def update_points_of(self, our_task, points):
jira_task = self.find_card(our_task.name)
self._set_points_of(jira_task, points)
our_task.point_cost = points
return our_task


def extract_status_updates(all_events):
last_updates = dict()
Expand Down Expand Up @@ -237,7 +240,7 @@ def from_form(cls, form):
kwargs = dict()
kwargs["server_url"] = "https://issues.redhat.com"
kwargs["token"] = form.token.data
kwargs["importer_cls"] = Importer
kwargs["importer_cls"] = SyncImporter
return cls(** kwargs)


Expand Down

0 comments on commit fa459d6

Please sign in to comment.