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

Empty start date and Task created as anon #89

Closed
quanvn opened this issue Jun 25, 2015 · 1 comment
Closed

Empty start date and Task created as anon #89

quanvn opened this issue Jun 25, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@quanvn
Copy link

quanvn commented Jun 25, 2015

Hi @nutso, please check the following points

  1. I dont know why, but it seem that the recurring task is created as anon, not as author of the original task so it cannot be recurred further. I change the order of your code to set User.current at the beginning before making new_issue and everything seems OK
  2. In rare case, if the issue has empty start date the calculation of time span yield error. I change is to take create date of the issue as start date on that case. Here are the modification I did
# calculate the original number of days between start and due date
ddate = issue.due_date.blank? ? Time.now.to_date : issue.due_date
sdate = issue.start_date.blank? ? issue.created_on.to_date : issue.start_date
timespan = ddate - sdate #issue.due_date - issue.start_date

while need_to_recur?
  usr_id = Setting.plugin_recurring_tasks['journal_attributed_to_user'].blank? ?
         issue.author_id : Setting.plugin_recurring_tasks['journal_attributed_to_user'].to_i
  defined_user = User.find(usr_id)             
  old_current_user = User.current
  User.current = defined_user

  new_issue = issue # default to existing issue
  if Setting.plugin_recurring_tasks['reopen_issue'] != "1"
    # duplicate issue 
    new_issue = issue.copy
  end      
  if !Setting.plugin_recurring_tasks['journal_attributed_to_user'].blank? 
     issue.init_journal(defined_user, "#{l(:recurring_task_created)} => #{new_issue.id}: #{new_issue.subj_date}")
  end         
  new_issue.due_date = next_scheduled_recurrence #41 previous_date_for_recurrence + recurrence_pattern
  new_issue.start_date = new_issue.due_date - timespan

...

@nutso
Copy link
Owner

nutso commented Jun 30, 2015

The beauty of git is the ability to see exactly what changed in a pull request :-). The description was helpful, but I had to go line-by-line and try to compare... It was easier to reimplement than to try to find exactly what changed.

1 -- confirmed and resolved

2 -- also reported in #90, I fixed it a slightly different way - keeping the existing definition of the next recurrence date, just defaulting to a timespan of 0 if an error occurs during the date calculation.

@nutso nutso closed this as completed Jun 30, 2015
@nutso nutso added this to the v2.0.0 milestone Jun 30, 2015
@nutso nutso added the bug label Jun 30, 2015
@nutso nutso self-assigned this Jun 30, 2015
nutso added a commit that referenced this issue Jun 30, 2015
nutso added a commit that referenced this issue Jun 30, 2015
nutso added a commit that referenced this issue Jun 30, 2015
nutso added a commit that referenced this issue Jun 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants