Skip to content

Conversation

maksbotan
Copy link

Added four new commands:

  • Start clocking in the current heading
  • Stop last unfinished line in the current heading
  • Recalculate duration after manual change of clock line
  • Display total time for the current heading

Please review whether my changes fit your architecture and style guides :)

Added four new commands:

- Start clocking in the current heading
- Stop last unfinished line in the current heading
- Recalculate duration after manual change of clock line
- Display total time for the current heading
@codecov-io
Copy link

Codecov Report

Merging #302 into master will decrease coverage by 0.46%.
The diff coverage is 38.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #302      +/-   ##
==========================================
- Coverage   84.38%   83.91%   -0.47%     
==========================================
  Files          49       50       +1     
  Lines        6794     6863      +69     
==========================================
+ Hits         5733     5759      +26     
- Misses       1061     1104      +43
Impacted Files Coverage Δ
ftplugin/orgmode/plugins/Date.py 85.27% <0%> (ø) ⬆️
ftplugin/orgmode/vimbuffer.py 70.34% <20%> (-0.89%) ⬇️
ftplugin/orgmode/liborgmode/orgdate.py 84.02% <36.84%> (-7.25%) ⬇️
ftplugin/orgmode/liborgmode/headings.py 83.55% <38.46%> (-1.18%) ⬇️
ftplugin/orgmode/liborgmode/logbook.py 44.11% <44.11%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce17a40...3cc8e15. Read the comment docs.

Copy link
Contributor

@akstrfn akstrfn left a comment

Choose a reason for hiding this comment

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

I've left some minor comments but in general LGTM ;)

from orgmode.py3compat.unicode_compatibility import *


def get_total_time(heading):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use generators:

total = sum(clockline for clockline in heading.logbook if not clockline.finished)
return total + sum(get_total_time(child) for child in heading.logbook)

# -2 to skip heading itself and :LOGBOOK:
clockline_index = position - current_heading.start - 2

if clockline_index < 0 or clockline_index >= len(current_heading.logbook):
Copy link
Contributor

Choose a reason for hiding this comment

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

len(current_heading.logbook) <= clockline_index < 0

self.logbook.clear()
for i, line in enumerate(self.document._content[self.start + 1:heading_end + 1]):
line_date = _text2orgdate(line)
if line_date is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

if line_date: is enough or if line_date is None: continue with unindenting the current if block

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.

3 participants