Skip to content

Adds Stat class and calculates additional statistics - #120

Merged
steven-esser merged 1 commit into
aboutcode-org:developfrom
arnav-mandal1234:stats
Apr 5, 2019
Merged

Adds Stat class and calculates additional statistics#120
steven-esser merged 1 commit into
aboutcode-org:developfrom
arnav-mandal1234:stats

Conversation

@arnav-mandal1234

Copy link
Copy Markdown
Collaborator

Adds Stat class to init.py and calculates various percent stats
Fixes : #5
Signed-off-by: arnav-mandal1234 arnav.mandal1234@gmail.com

Comment thread src/deltacode/utils.py Outdated
elif not delta.is_unmodified():
yield delta.to_dict()

def stats(deltacode):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this function if you are just going to run deltacode.stats.percent_to_dict()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaJuRG so from the cli.py file I directly call the stats.to_dict() method?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment thread src/deltacode/__init__.py Outdated
self.removed = 0
self.moved = 0
self.modified = 0
self.unmodified = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these field names should be prefixed with num_

Comment thread src/deltacode/__init__.py Outdated
self.removed_percent = 0
self.moved_percent = 0
self.modified_percent = 0
self.unmodified_percent = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should switch these field names around: percent_*

Comment thread src/deltacode/__init__.py Outdated
self.modified_percent = percent(self.modified, self.old_files_count)
self.unmodified_percent = percent(self.unmodified, self.old_files_count)

def percent_to_dict(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably rename this to simply to_dict, since this is a Stat object.

@arnav-mandal1234 arnav-mandal1234 Apr 5, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaJuRG I named it as percent_to_dict because we currently need only percent stats, in future if we want to get all the data variables of this class then we can use another method to_dict() for that case. Should I rename this to to_dict()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would rename this.

Comment thread src/deltacode/__init__.py Outdated
self.removed_percent = percent(self.removed, self.old_files_count)
self.moved_percent = percent(self.moved, self.old_files_count)
self.modified_percent = percent(self.modified, self.old_files_count)
self.unmodified_percent = percent(self.unmodified, self.old_files_count)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just do the math at this level instead of calling percent(x, y)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaJuRG since we need to calculate percent, again and again, I made a util function, such that we can use this in the future as well if we need it. Should I calculate here only and delete the percent function?

@steven-esser steven-esser Apr 5, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arnav-mandal1234 Yes, you are right, that makes sense to me. You should probably rename it calculate_percent though

Adds Stat class to __init__.py and calculates various percent stats
Fixes : #5
Signed-off-by: arnav-mandal1234 <arnav.mandal1234@gmail.com>
@steven-esser
steven-esser merged commit 14bbc68 into aboutcode-org:develop Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants