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

some fix #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl HabitCtl {

for habit in self.get_todo(&current) {
self.print_habit_row(&habit, log_from, current.clone());
let l = format!("[y/n/s/⏎] ");
let l = "[y/n/s/⏎] ".to_string();

let mut value;
loop {
Expand All @@ -304,9 +304,9 @@ impl HabitCtl {
}
}

if value != "" {
if !value.is_empty() {
self.entry(&Entry {
date: current.clone(),
date: current,
habit: habit.name,
value,
});
Expand Down Expand Up @@ -362,7 +362,7 @@ impl HabitCtl {

for line in file.lines() {
let l = line.unwrap();
if l == "" {
if l.is_empty() {
continue;
}
let split = l.split('\t');
Expand All @@ -388,20 +388,20 @@ impl HabitCtl {
}

fn day_status(&self, habit: &Habit, date: &NaiveDate) -> DayStatus {
if let Some(entry) = self.get_entry(&date, &habit.name) {
if let Some(entry) = self.get_entry(date, &habit.name) {
if entry.value == "y" {
DayStatus::Done
} else if entry.value == "s" {
DayStatus::Skipped
} else if self.habit_satisfied(habit, &date) {
} else if self.habit_satisfied(habit, date) {
DayStatus::Satisfied
} else if self.habit_skipified(habit, &date) {
} else if self.habit_skipified(habit, date) {
DayStatus::Skipified
} else {
DayStatus::NotDone
}
} else {
if self.habit_warning(habit, &date) {
if self.habit_warning(habit, date) {
DayStatus::Warning
} else {
DayStatus::Unknown
Expand Down Expand Up @@ -508,13 +508,13 @@ impl HabitCtl {
fn first_date(&self) -> Option<NaiveDate> {
self.get_entries()
.first()
.and_then(|entry| Some(entry.date.clone()))
.and_then(|entry| Some(entry.date))
}

fn last_date(&self) -> Option<NaiveDate> {
self.get_entries()
.last()
.and_then(|entry| Some(entry.date.clone()))
.and_then(|entry| Some(entry.date))
}

fn get_score(&self, score_date: &NaiveDate) -> f32 {
Expand All @@ -529,7 +529,7 @@ impl HabitCtl {
.habits
.iter()
.map(|habit| {
let status = self.day_status(&habit, &score_date);
let status = self.day_status(habit, score_date);
habit.every_days > 0
&& (status == DayStatus::Done || status == DayStatus::Satisfied)
})
Expand All @@ -540,7 +540,7 @@ impl HabitCtl {
.habits
.iter()
.map(|habit| {
let status = self.day_status(&habit, &score_date);
let status = self.day_status(habit, score_date);
habit.every_days > 0
&& (status == DayStatus::Skipped || status == DayStatus::Skipified)
})
Expand Down