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

[IMP] shift: Better logging for generating next planning #513

Open
wants to merge 3 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions shift/models/cooperative_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ def _cron_compute_counter_irregular(self, today=False):

domain = self._get_irregular_worker_domain(today)
irregular = self.search(domain)
_logger.info(
"changing irregular counter (today = '%s', journal_id = '%s', ids = '%s')",
today,
journal.id,
irregular.ids,
)
for status in irregular:
delta = (today - status.irregular_start_date).days
if delta and delta % self._period == 0 and status not in journal.line_ids:
Expand Down
15 changes: 15 additions & 0 deletions shift/models/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def _generate_next_planning(self):
planning = self._get_next_planning(last_seq)
planning = planning.with_context(visualize_date=date)

_logger.info(
"generating next shift planning:"
" (planning = '%s', last_planning_seq = '%s', next_planning_date = '%s')",
planning.name,
last_seq,
date,
)

if not planning.task_template_ids:
_logger.error("Could not generate next planning: no task template defined.")
return
Comment on lines 113 to 115
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this raise an error?

Expand All @@ -112,6 +120,13 @@ def _generate_next_planning(self):
config.set_param("shift.last_planning_seq", planning.sequence)
config.set_param("shift.next_planning_date", next_date)

_logger.info(
"setting next values:"
" (last_planning_seq = '%s', next_planning_date = '%s')",
planning.sequence,
next_date,
)

@api.model
def get_future_shifts(
self,
Expand Down
1 change: 1 addition & 0 deletions shift/newsfragments/513.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve logging of crons.