Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New status command #1741

Merged
merged 9 commits into from May 22, 2015
Merged

New status command #1741

merged 9 commits into from May 22, 2015

Conversation

@da2x
Copy link
Contributor

da2x commented May 21, 2015

From issue #1740.

Sample output:

39 output files modified since last deployment 4 hours and 31 minutes ago.
4 days and 22 hours to next scheduled post.
78 posts in total, 1 scheduled, and 0 drafts.

Counting new posts is out. Tracking whether last build succeeded seemed less useful when I started working on it, so I dropped that too. Checking for version should be done in version plugin.

da2x added 5 commits May 21, 2015
""" Site status. """
name = "status"

doc_usage = "[[preset [preset...]]"

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska May 21, 2015

Member

not really, at least not in this iteration.


self.site.scan_posts()

timestamp_path = os.path.join(self.site.config["CACHE_FOLDER"], "lastdeploy")

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska May 21, 2015

Member

On a side note, does github_deploy write to this file? If not, it should.

This comment has been minimized.

Copy link
@da2x

da2x May 21, 2015

Author Contributor

It does now.

if last_deploy:

if last_deploy_offset.days > 0:
last_deploy_offsetstr = "{0} days and {1} hours".format(str(int(last_deploy_offset.days)), str(int(last_deploy_offset.seconds / 60 / 60)))

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska May 21, 2015

Member

Why do you need this str(int()) dance?

Just use {0:.0f} days and {1:.0f} hours as the format string. It will guarantee zero decimal places. Even if not for this, str.format() does not need strings as its arguments — and it’s even better to give ints and floats so you can format them more precisely.


if posts_scheduled > 0 and post_scheduled_nearest_offset is not None:
if post_scheduled_nearest_offset.days > 0:
nearest_scheduled_timestr = "{0} days and {1} hours".format(str(int(post_scheduled_nearest_offset.days)), str(int(post_scheduled_nearest_offset.seconds / 60 / 60)))

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska May 21, 2015

Member

Deduplication: write a display_time function that takes offset as an argument and is used for generating pretty last_deploy_offset and post_scheduled_nearest_offset text

nearest_scheduled_timestr = "{0} minutes".format(str(int(((post_scheduled_nearest_offset.seconds / 60) // 60) * 60)))
print("{0} to next scheduled post.".format(nearest_scheduled_timestr))

print("{0:,} posts in total, {1:,} scheduled, and {2:,} drafts.".format(posts_count, posts_scheduled, posts_drafts))

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska May 21, 2015

Member

Sounds better if we used plain numbers (123456 vs 123,456) here.

da2x added 4 commits May 21, 2015
Conflicts:
	CHANGES.txt
da2x added a commit that referenced this pull request May 22, 2015
New status command
@da2x da2x merged commit bebde03 into master May 22, 2015
3 checks passed
3 checks passed
continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@da2x da2x deleted the status-command branch May 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.