Skip to content

Commit

Permalink
[gitqm] Address the issues raised in chaoss#902
Browse files Browse the repository at this point in the history
This commit is in reference to the issues raised
- fix the date normalizing errors and also problems
related to the timezone
- made the '.git' string optional
- fix the value error

Signed-off-by: Venu Vardhan Reddy Tekula <[email protected]>
  • Loading branch information
vchrombie committed Aug 21, 2021
1 parent 3e1ea7b commit 7ade8d3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions grimoire_elk/enriched/gitqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

from .qmenrich import QMEnrich

from datetime import timezone

from perceval.backend import uuid
from grimoirelab_toolkit.datetime import str_to_datetime

MAX_SIZE_BULK_ENRICHED_ITEMS = 200

URL_PATTERN = "^(https|git)(://|@)([^/:]+)[/:]([^/:]+)/(.+).git$"
URL_PATTERN = "^(https|git)(://|@)([^/:]+)[/:]([^/:]+)/(.+)[.git]?$"

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -68,7 +70,7 @@ def normalized_date(self, dt):
processed_dt = None

if dt and dt is not None:
processed_dt = str_to_datetime(dt).replace(hour=0, minute=0, second=0, microsecond=0)
processed_dt = str_to_datetime(dt).replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=timezone.utc)
processed_dt = processed_dt.isoformat()

return processed_dt
Expand All @@ -78,8 +80,8 @@ def extract_project(self, item):

def extract_commit_metric(self, item):
commit = item['data']

commit_date = self.normalized_date(commit['CommitDate'])

files = commit['files']

added = 0
Expand All @@ -88,10 +90,11 @@ def extract_commit_metric(self, item):
files_changed = []

for file in files:
added += int(file['added']) if file['added'].isdigit() else 0
removed += int(file['removed']) if file['removed'].isdigit() else 0
actions += 1 if file['action'] else 0
files_changed.append(file['file'])

added += int(file['added']) if 'added' in file and file['added'].isdigit() else 0
removed += int(file['removed']) if 'removed' in file and file['removed'].isdigit() else 0
actions += 1 if 'action' in file else 0
files_changed.append(file['file'] if 'file' in file else None)

if 'project' in self.date_items.keys():

Expand Down

0 comments on commit 7ade8d3

Please sign in to comment.