Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Keep the demo's bookings in the week of the build

Guido Boyke478aedce0796
diff --git a/lib/lalabase/demo/fiction.rb b/lib/lalabase/demo/fiction.rb
index 3469441..3ef1e02 100644
--- a/lib/lalabase/demo/fiction.rb
+++ b/lib/lalabase/demo/fiction.rb
@@ -90,7 +90,8 @@ module Lalabase
status: 'backlog', priority: 'normal', assignee: :svenja }
].freeze
- # Minutes per person and day, on the ticket at that index.
+ # Minutes per person and day, on the ticket at that index. All of it falls in the
+ # week of the build (World#booked_on): CHAT[:answer] sums Ole's week.
TIME = [
{ person: :malte, days_ago: 0, minutes: 150, ticket: 2,
de: 'Upload der Fotos, Vorschau', en: 'Photo upload, preview' },
diff --git a/lib/lalabase/demo/world.rb b/lib/lalabase/demo/world.rb
index a3d20f1..92cd125 100644
--- a/lib/lalabase/demo/world.rb
+++ b/lib/lalabase/demo/world.rb
@@ -141,13 +141,17 @@ module Lalabase
creator = person(entry[:person])
session = TimeSession.new(organisation: @organisation, project: project(:deichblick),
ticket: entry[:ticket] && ticket(entry[:ticket]), creator: creator,
- duration: entry[:minutes], occurred_on: @now - entry[:days_ago].days,
+ duration: entry[:minutes], occurred_on: booked_on(entry[:days_ago]),
description: entry.fetch(@locale))
succeed!(Actors::SaveTimeSession.call(time_session: session, attributes: {},
group_change: { requested: false }, current_user: creator))
end
end
+ # Never before the start of the week: the stored answer speaks of the hours of
+ # "this week", and on a Monday two days back is the week before.
+ def booked_on(days_ago) = [@now - days_ago.days, @now.beginning_of_week].max
+
def add_notes
@notes = Fiction::NOTES.each_with_index.map do |entry, index|
params = { title: entry.fetch(@locale), content: dated(entry[:content].fetch(@locale)),
diff --git a/spec/lib/lalabase/demo/world_spec.rb b/spec/lib/lalabase/demo/world_spec.rb
index b9d22dc..6a3cf5b 100644
--- a/spec/lib/lalabase/demo/world_spec.rb
+++ b/spec/lib/lalabase/demo/world_spec.rb
@@ -89,6 +89,23 @@ RSpec.describe Lalabase::Demo::World do
end
end
+ # The stored answer speaks of "4:30 hours this week". Built on a Monday at the hour
+ # of the nightly reset, a booking two days back would land in the week before, and
+ # the time list and the answer would contradict each other.
+ it 'keeps every booking in the week of the build, so the stored answer adds up on a Monday' do
+ monday = Time.zone.local(2026, 10, 19, 3, 0)
+ world = Prosopite.pause do
+ travel_to(monday) { described_class.new(locale: :en, now: monday, password: password).build }
+ end
+ ActsAsTenant.without_tenant do
+ sessions = TimeSession.where(organisation: world.organisation)
+ expect(sessions.pluck(:occurred_on)).to all(be_between(monday.beginning_of_week, monday))
+ ole_on_the_statement = sessions.where(creator: world.person(:ole), ticket: world.ticket(fiction::CHAT[:ticket]))
+ expect(ole_on_the_statement.sum(:duration)).to eq(270)
+ expect(world.chat.chatposts.find_by(role: 'assistant').content).to include('4:30 hours on it this week')
+ end
+ end
+
it 'marks notes, comments and meetings for the search when asked' do
world = build(embeddings: true)
ActsAsTenant.without_tenant do