Fix Sprint numbering for 2023

My PM delayed the start of our "first" sprint of the year, and this
wreaked havoc with my algorithm. Granted, I often need to tweak it
each year.
This commit is contained in:
Howard Abrams 2023-02-01 08:19:20 -08:00
parent 60a960b4fe
commit dcdd481713
2 changed files with 80 additions and 27 deletions

View file

@ -45,12 +45,13 @@ At the beginning of the year, I choose a theme, and make a list for the upcoming
#+begin_src emacs-lisp :noweb yes
(defvar sprint-nicknames
(--map (replace-regexp-in-string " *[:#].*" "" (first it))
'<<sprint-names-2022()>>)
'<<sprint-names-2023()>>)
"List of 26 Sprint Nicknames from A to Z.")
#+end_src
** 2023
How about a list of Ent names?
#+NAME: sprint-names-2023
- ashskin
- birchblossom
- cedar king
@ -203,7 +204,7 @@ Came up with a list of somewhat well-known cities throughout the world (at least
- zippy-zinder
* Sprint Boundaries
Function to help in calculating dates and other features of a two-week sprint that starts on Thursday and ends on a Wednesday… how we work at my job.
Function to help in calculating dates and other features of a two-week sprint that starts on Tuesday and ends on a Monday… how we work at my job.
Emacs have an internal rep of a time.
#+begin_src emacs-lisp
@ -221,7 +222,7 @@ Emacs have an internal rep of a time.
** Sprint Numbering
My Sprint starts on Thursday, but this sometimes changed, so let's make this a variable:
My Sprint starts on Tuesday, but this sometimes changed, so let's make this a variable:
#+begin_src emacs-lisp
(defvar sprint-starting-day 2 "The day of the week the sprint begins, where 0 is Sunday.")
#+end_src
@ -230,47 +231,50 @@ We label our sprint based on the week number that it starts. Note that on a Mond
#+begin_src emacs-lisp
(defun sprint-week-num (&optional date)
"Return the week of the current year (or DATE), but starting
the week at Thursday to Wednesday."
the week at Tuesday to Monday."
(let* ((d (get-date-time date))
(dow (nth 6 (decode-time d))) ; Day of the week 0=Sunday
(week (->> d ; Week number in the year
(format-time-string "%U")
string-to-number)))
(week (thread-last d ; Week number in the year
(format-time-string "%U")
string-to-number)))
(if (>= dow sprint-starting-day)
(1+ week)
week)))
#+end_src
Let's have these tests to make sure, and yeah, perhaps we update this at the beginning of each year.
Let's have these tests to make of this /weekly/ perspective:
#+begin_src emacs-lisp :tangle no
(ert-deftest sprint-week-num-test ()
(should (= (sprint-week-num "2023-01-09") 2)) ; Monday previous week
(should (= (sprint-week-num "2023-01-10") 3)) ; Tuesday current week
(should (= (sprint-week-num "2023-01-17") 4))) ; Tuesday next week
(should (= (sprint-week-num "2023-01-01") 1)) ; Monday previous week
(should (= (sprint-week-num "2023-01-03") 2)) ; Tuesday ... this week
(should (= (sprint-week-num "2023-01-09") 2)) ; Monday, next week, part of last
(should (= (sprint-week-num "2023-01-10") 3))) ; Tuesday next week
#+end_src
My company has sprints two weeks long, we could be see that on even week numbers, the /sprint/ is actually the previous week's number.
And it appears that my PM for this year, is a differently off by a week number.
And it appears that my PM for this year didnt start our first Sprint until the 17th.
#+begin_src emacs-lisp
(defun sprint-number (&optional date)
"Return the current sprint number, with some assumptions that
each sprint is two weeks long, starting on Tuesday."
(let ((num (sprint-week-num date)))
(if (cl-oddp num)
(1- num)
(- num 2))))
(- num 4) ; CHANGEME each year!
(- num 3))))
#+end_src
And some tests to verify that:
#+begin_src emacs-lisp :tangle no
(ert-deftest sprint-number-test ()
(should (= (sprint-number "2023-01-09") 0))
(should (= (sprint-number "2023-01-10") 2))
(should (= (sprint-number "2023-01-17") 2))
(should (= (sprint-number "2023-01-18") 2))
(should (= (sprint-number "2023-01-23") 2))
(should (= (sprint-number "2023-01-24") 4)))
(should (= (sprint-number "2023-01-09") -1)) ;; Ignore
(should (= (sprint-number "2023-01-10") -1))
(should (= (sprint-number "2023-01-17") 1))
(should (= (sprint-number "2023-01-18") 1))
(should (= (sprint-number "2023-01-23") 1))
(should (= (sprint-number "2023-01-24") 1))
(should (= (sprint-number "2023-01-30") 1))
(should (= (sprint-number "2023-01-31") 3)))
#+end_src
** Sprint File Name
I create my org-file notes based on the Sprint number.
@ -332,7 +336,7 @@ These test won't pass any more, as the nickname of the sprint changes from year
** Sprint Start and End
I want to print the beginning and ending of the sprint, where we have a sprint number or a data, and we can give the dates that bound the sprint. This odd function calculates this based on knowing the date of the /first thursday/ of the year, so I need to begin the year changing this value. I should fix this.
I want to print the beginning and ending of the sprint, where we have a sprint number or a data, and we can give the dates that bound the sprint. This odd function calculates this based on knowing the date of the /first Tuesday/ of the year, so I need to begin the year changing this value. I should fix this.
#+begin_src emacs-lisp
(defun sprint-range (&optional number-or-date)
@ -342,8 +346,9 @@ I want to print the beginning and ending of the sprint, where we have a sprint n
(let* ((num (if (or (null number-or-date) (stringp number-or-date))
(sprint-number number-or-date)
number-or-date))
(year-start "2020-01-02") ; First Thursday of the year
(time-start (-> year-start ; Converted to time
;; CHANGEME each year to mark the first day of the first sprint:
(year-start "2023-01-17")
(time-start (-> year-start ; Converted to time
get-date-time
float-time))
(day-length (* 3600 24)) ; Length of day in seconds
@ -371,8 +376,8 @@ Format the start and end so that we can insert this directly in the org file:
And validate with a test:
#+begin_src emacs-lisp
(ert-deftest sprint-date-range ()
(should (equal (sprint-date-range 7)
(sprint-date-range "2020-02-17"))))
(should (equal (sprint-date-range 1)
(sprint-date-range "2023-01-17"))))
#+end_src
** Pre-scheduled Dates
@ -423,11 +428,11 @@ The following functions /were/ helpful at times. But I'm not sure I will use the
#+begin_src emacs-lisp :tangle no
(defun sprint-day-start (&optional date)
"Return a relative number of days to the start of the current sprint. For instance, if today was Friday, and the sprint started on Thursday, this would return -1."
"Return a relative number of days to the start of the current sprint. For instance, if today was Friday, and the sprint started on Tuesday, this would return -1."
(first (sprint-day-range date)))
(defun sprint-day-end (&optional date)
"Return a relative number of days to the end of the current sprint. For instance, if today was Monday, and the sprint will end on Wednesday, this would return 3."
"Return a relative number of days to the end of the current sprint. For instance, if today was Monday, and the sprint will end on Monday, this would return 3."
(second (sprint-day-range date)))
#+end_src

48
templates/sprint.org Normal file
View file

@ -0,0 +1,48 @@
#+TITLE: `(sprint-current-name)`
#+AUTHOR: `user-full-name`
#+EMAIL: `user-mail-address`
#+DATE: `(sprint-date-range)`
#+CATEGORY: sprint
#+FILETAGS: :work:
* Work Issues
$0
* Onboarding Work
See [[file:Onboarding-Work.org][Onboard-Work]] for all details.
* Distractions and Support
Anything that doesn't fit the above goes here.
* Meeting Notes :meeting:
* Scrum Status :status:
* Sprint Demonstration
New approach for giving presentations. First create [[file:`(file-name-sans-extension (buffer-name))`-demo.org][`(file-name-sans-extension (buffer-name))`-demo.org]], and then add the bits to the code below.
#+BEGIN_SRC emacs-lisp :results silent
(defun org-present-file (filename)
(find-file (filename))
(delete-other-windows)
(org-present))
(demo-it-create :advanced-mode :single-window
(org-present-file "`(file-name-sans-extension (buffer-name))`-demo.org")
(org-present-next)
(osx-browse-url-forwork "https://...")
(demo-it-load-fancy-file "~/work/wpc4/wpc/dashboards/wpc4/hypervisor.yml" :line 116 133)
;; ...
)
#+END_SRC
Have fun and start the show: =demo-it-start= and hit ~F5~.
* Notes for Next Sprint
#+DESCRIPTION: Notes taken during Sprint #`(sprint-number)`
#+PROPERTY: header-args: :results drawer :tangle no :eval no-export :comments org
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil skip:nil author:nil email:nil creator:nil timestamp:nil ^:nil
# Local Variables:
# eval: (org-content 2)
# End: