Skip to content

Commit

Permalink
feat: modify namespace and metrics and remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Sep 7, 2024
1 parent d9097c1 commit a7de751
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
32 changes: 2 additions & 30 deletions src/plugin/connector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,13 @@ def dispatch_request(
auth = self.get_auth(secret_data)

try:
max_results = params.get("maxResults")
start_at = params.get("startAt")
total_count = params.get("total_count")
if max_results and start_at and total_count:
for response in self._pagination_with_count(
method, url, headers, auth, params, data
):
yield response

else:
for response in self._pagination(
method, url, headers, auth, params, data
):
yield response
for response in self._pagination(method, url, headers, auth, params, data):
yield response

except Exception as e:
_LOGGER.error(f"[dispatch_request] Error {e}")
raise ERROR_UNKNOWN(message=e)

@staticmethod
def _pagination_with_count(
method: str,
url: str,
headers: dict,
auth: HTTPBasicAuth,
params: dict,
data: dict = None,
) -> list:
responses = []
while True:
print(url, params)

@staticmethod
def _pagination(
method: str,
Expand All @@ -74,7 +49,6 @@ def _pagination(
) -> list:
responses = []
while True:
print(url, params)
response = requests.request(
method,
url,
Expand All @@ -89,8 +63,6 @@ def _pagination(
else:
response_values = response_json.get("values")

print(response_json)

_LOGGER.debug(
f"[dispatch_request] {url} {response.status_code} {response.reason}"
)
Expand Down
1 change: 0 additions & 1 deletion src/plugin/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def collect_metrics(cls, cloud_service_group: str):
_METRIC_DIR, cloud_service_group, dirname, filename
)
info = utils.load_yaml_from_file(file_path)
print(file_path)
if filename == "namespace.yaml":
yield make_response(
namespace=info,
Expand Down
11 changes: 11 additions & 0 deletions src/plugin/manager/issue_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from datetime import datetime
from typing import Generator

from plugin.connector.project_connector import ProjectConnector
Expand Down Expand Up @@ -73,6 +74,11 @@ def _list_issue_from_project(
"external_link": f"https://{domain}.atlassian.net/browse/{issue_info['key']}",
}

issue_created: str = issue_info.get("fields", {}).get("created")
if issue_created:
issue_created_display = issue_created.split("T")[0]
issue_info["issue_created_display"] = issue_created_display

cloud_service = make_cloud_service(
name=issue_info["fields"]["summary"],
cloud_service_type=self.cloud_service_type,
Expand All @@ -95,3 +101,8 @@ def _list_issue_from_project(
]
],
)

@staticmethod
def convert_datetime(created_at: str) -> str:
datetime_obj = datetime.strptime(created_at, "%Y-%m-%d")
return datetime_obj.strftime("%Y-%m-%d")
4 changes: 4 additions & 0 deletions src/plugin/metrics/Projects/issue/projects_issue_count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ query_options:
- key: data.fields.status.name
name: Status
default: true
- key: data.fields.priority.name
name: Priority
- key: data.fields.assignee.displayName
name: Assignee
- key: data.fields.issuetype.name
name: Issue Type
- key: data.fields.reporter.displayName
name: Reporter
- key: data.issue_created_display
name: Created Date
fields:
value:
operator: count
Expand Down

0 comments on commit a7de751

Please sign in to comment.