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

various improvements #353

Merged
merged 2 commits into from
Jan 13, 2025
Merged
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/autoflake
Expand Down
12 changes: 7 additions & 5 deletions gazu/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,20 +1067,22 @@ def publish_preview(
return new_comment, preview_file


def publish_comments_previews(task, comments=[], client=default):
def batch_comments(comments=[], task=None, client=default):
"""
Publish a list of comments (with attachments and previews) for given task.
Each dict comments may contain a list of attachment files path and preview
files path in the keys "attachment_files" and "preview_files".
files path in the keys "attachment_files" and "preview_files". If no task is
given each comments needs to have a task_id key.

Args:
task (str / dict): The task dict or the task ID.
comments (list): List of comments to publish.
task (str / dict): The task dict or the task ID.

Returns:
list: List of created comments.
"""
task = normalize_model_parameter(task)
if task is not None:
task = normalize_model_parameter(task)

files = {}
for x, comment in enumerate(comments):
Expand All @@ -1093,7 +1095,7 @@ def publish_comments_previews(task, comments=[], client=default):

files["comments"] = (None, json.dumps(comments), "application/json")
return raw.upload(
"actions/tasks/%s/add-comments-previews" % task["id"],
"actions/tasks/%sbatch-comment" % ("%s/" % task["id"] if task else ""),
file_path=None,
files=files,
client=client,
Expand Down
Loading