Skip to content

Commit

Permalink
chore: format files for 'pre-commit'
Browse files Browse the repository at this point in the history
  • Loading branch information
yjane99 committed Apr 12, 2024
1 parent 046e5b0 commit 5f93eeb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const TiptapRenderer = ({ message, user, isScrolling = false, isTruncated
editable: false,
editorProps: {
attributes: {
class: isTruncated ? 'tiptap-renderer line-clamp-3' : 'tiptap-renderer'
class: isTruncated ? 'tiptap-renderer line-clamp-3' : 'tiptap-renderer'
}
},
enableCoreExtensions: true,
Expand Down
23 changes: 13 additions & 10 deletions raven/api/raven_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,31 @@ def get_all_votes(poll_id):
poll_doc = frappe.get_cached_doc("Raven Poll", poll_id)

if poll_doc.is_anonymous:
frappe.throw(_("This poll is anonymous. You do not have permission to access the votes."), frappe.PermissionError)
frappe.throw(
_("This poll is anonymous. You do not have permission to access the votes."),
frappe.PermissionError,
)
else:
# Get all votes for this poll
votes = frappe.get_all(
"Raven Poll Vote",
filters={"poll_id": poll_id},
fields=["name", "option", "user_id"]
"Raven Poll Vote", filters={"poll_id": poll_id}, fields=["name", "option", "user_id"]
)

# Initialize results dictionary
results = {option.name: { 'users': [], 'count': option.votes } for option in poll_doc.options if option.votes}
results = {
option.name: {"users": [], "count": option.votes} for option in poll_doc.options if option.votes
}

# Process votes
for vote in votes:
option = vote['option']
results[option]['users'].append(vote['user_id'])
option = vote["option"]
results[option]["users"].append(vote["user_id"])

# Calculate total votes
total_votes = sum(result['count'] for result in results.values())
total_votes = sum(result["count"] for result in results.values())

# Calculate percentages
for result in results.values():
result['percentage'] = (result['count'] / total_votes) * 100
result["percentage"] = (result["count"] / total_votes) * 100

return results
return results
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ def on_update(self):
server_script.disabled = self.disabled
server_script.save()


def on_trash(self):
"""
1. If the 'scheduler_event_id' is set, delete the Server Script of type 'Scheduler Event' with the name 'scheduler_event_id'.
"""
if self.scheduler_event_id:
frappe.db.delete('Server Script', self.scheduler_event_id)

frappe.db.delete("Server Script", self.scheduler_event_id)

def create_scheduler_event(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ class RavenWebhook(Document):

def before_insert(self):
# 1. Check if webhook name is unique
webhook = frappe.get_all('Raven Webhook', filters={'name': self.name})
webhook = frappe.get_all("Raven Webhook", filters={"name": self.name})
if webhook:
frappe.throw(_("Webhook name already exists"))


def validate(self):
# 1. Check if webhook_data and webhook_headers are unique

Expand Down

0 comments on commit 5f93eeb

Please sign in to comment.