はじめに
hkob の雑記録の第42回目は、昨日のオートメーションで抜けていた次のスプリントの日付設定を追加します。
昨日の結果
昨日のオートメーションが 7:15 に実施されましたが、Next の日付が設定されていませんでした。Current の日付は自動的に設定されますが、Next はされないのを忘れていました。

実際、スクリプトにも次のタスクの日付設定がされていました。この部分を抜いてしまいました。
today = Date.today cwday = today.cwday monday = today + (8 - cwday) sunday = monday + 6 next_sprint = sprint_db.query_database(sp["Sprint status"].filter_equals("Next")).first nsdp = next_sprint.properties["Dates"] next_sprint_week_key = if nsdp.start_date.nil? nsdp.start_date = monday nsdp.end_date = sunday next_sprint.save next_sprint.properties["week_id"].formula["string"] else next_sprint.properties["week_id"].formula["string"] end next_sprint_title = next_sprint.title if next_sprint_week_key != next_sprint_title next_sprint.properties["Sprint name"].text_objects.rich_text_objects = next_sprint_week_key next_sprint.save end
Next sprint のプロパティ設定
昨日の変数を定義の下で Next スプリントのタイトルを修正していましたが、その部分を以下のように「Dates」「Sprint name」「map」の三つのプロパティを設定するように変更しました。

1. Dates の数式
Date は次の週の日付範囲を設定します。Ruby では以下の式で計算しています。
today = Date.today cwday = today.cwday monday = today + (8 - cwday) sunday = monday + 6
フォーミュラでは以下のようになります。lets のおかげでほとんどそのままですね。
lets( today, prop("トリガーされた日付"), cwday, today.day(), monday, today.dateAdd(8 - cwday, "days"), sunday, monday.dateAdd(6, "days"), monday.dateRange(sunday) )
2. Sprint name
日付を設定したタイミングですぐに Formula は計算できないので、Formula と同じ数式を計算します。これもトリガーされた時間から作成すればいいでしょう。来週のものなので、7日足しています。
prop("トリガーされた日付").dateAdd(9, "hours").dateAdd(7, "days").formatDate("GGGG-WW")
3. map
ここまでやって手動のトリガで実行しましたが、うまくタスクが繋がりませんでした。map が連携されていなかったためです。このため、map はここで設定することにしました。
おわりに
これで来週はちゃんと動作するはずです。昨日の記事には今日の記事で修正があることを追記しておきます。