-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/report #6
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
Feat/report #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright (c) 2026, Build With Hussain and contributors | ||
| // For license information, please see license.txt | ||
|
|
||
| frappe.query_reports["Registration Report"] = { | ||
| filters: [ | ||
| { | ||
| fieldname: "webinar", | ||
| label: __("Webinar"), | ||
| fieldtype: "Link", | ||
| options: "Zoom Webinar", | ||
| reqd: 1, | ||
| }, | ||
| ], | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "add_total_row": 0, | ||
| "add_translate_data": 0, | ||
| "columns": [], | ||
| "creation": "2026-01-17 16:43:07.141951", | ||
| "disabled": 0, | ||
| "docstatus": 0, | ||
| "doctype": "Report", | ||
| "filters": [], | ||
| "idx": 0, | ||
| "is_standard": "Yes", | ||
| "json": "{}", | ||
| "letter_head": null, | ||
| "modified": "2026-01-17 16:53:48.908719", | ||
| "modified_by": "Administrator", | ||
| "module": "Zoom Integration", | ||
| "name": "Registration Report", | ||
| "owner": "Administrator", | ||
| "prepared_report": 0, | ||
| "ref_doctype": "Zoom Webinar Registration", | ||
| "report_name": "Registration Report", | ||
| "report_type": "Script Report", | ||
| "roles": [ | ||
| { | ||
| "role": "System Manager" | ||
| }, | ||
| { | ||
| "role": "Zoom Manager" | ||
| } | ||
| ], | ||
| "timeout": 0 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # Copyright (c) 2026, Build With Hussain | ||
| # For license information, please see license.txt | ||
|
|
||
| import frappe | ||
| from frappe import _ | ||
|
|
||
|
|
||
| def execute(filters=None): | ||
| columns = get_columns() | ||
| data = get_data(filters or {}) | ||
| return columns, data | ||
|
|
||
|
|
||
| def get_columns(): | ||
| return [ | ||
| { | ||
| "label": _("User Email"), | ||
| "fieldname": "user", | ||
| "fieldtype": "Data", | ||
| "width": 200, | ||
| }, | ||
| { | ||
| "label": _("First Name"), | ||
| "fieldname": "first_name", | ||
| "fieldtype": "Data", | ||
| "width": 180, | ||
| }, | ||
| { | ||
| "label": _("Last Name"), | ||
| "fieldname": "last_name", | ||
| "fieldtype": "Data", | ||
| "width": 180, | ||
| }, | ||
| { | ||
| "label": _("Synced from Zoom"), | ||
| "fieldname": "synced_from_zoom", | ||
| "fieldtype": "Check", | ||
| "width": 200, | ||
| }, | ||
| { | ||
| "label": _("Auto Registered"), | ||
| "fieldname": "custom_auto_registered", | ||
| "fieldtype": "Check", | ||
| "width": 200, | ||
| }, | ||
| { | ||
| "label": _("Registrant ID"), | ||
| "fieldname": "registrant_id", | ||
| "fieldtype": "Data", | ||
| "width": 200, | ||
| }, | ||
| { | ||
| "label": _("Join URL"), | ||
| "fieldname": "join_url", | ||
| "fieldtype": "Data", | ||
| "width": 200, | ||
| }, | ||
| { | ||
| "label": _("UTM Source"), | ||
| "fieldname": "utm_source", | ||
| "fieldtype": "Data", | ||
| "width": 120, | ||
| }, | ||
| { | ||
| "label": _("UTM Medium"), | ||
| "fieldname": "utm_medium", | ||
| "fieldtype": "Data", | ||
| "width": 120, | ||
| }, | ||
| { | ||
| "label": _("UTM Campaign"), | ||
| "fieldname": "utm_campaign", | ||
| "fieldtype": "Data", | ||
| "width": 150, | ||
| }, | ||
| { | ||
| "label": _("UTM Term"), | ||
| "fieldname": "utm_term", | ||
| "fieldtype": "Data", | ||
| "width": 120, | ||
| }, | ||
| { | ||
| "label": _("UTM Content"), | ||
| "fieldname": "utm_content", | ||
| "fieldtype": "Data", | ||
| "width": 120, | ||
| }, | ||
| ] | ||
|
|
||
|
|
||
| def get_data(filters): | ||
| values = {"webinar": filters.get("webinar")} | ||
|
|
||
| # Base registration data | ||
| query = """ | ||
| SELECT | ||
| zwreg.name AS registration, | ||
| zwreg.user, | ||
| zwreg.first_name, | ||
| zwreg.last_name, | ||
| zwreg.synced_from_zoom, | ||
| zwreg.registrant_id, | ||
| zwreg.join_url, | ||
| zwreg.custom_auto_registered | ||
| FROM `tabZoom Webinar Registration` zwreg | ||
| WHERE zwreg.webinar = %(webinar)s | ||
| ORDER BY zwreg.user | ||
| """ | ||
|
|
||
| records = frappe.db.sql(query, values, as_dict=True) | ||
|
|
||
| if not records: | ||
| return [] | ||
|
|
||
| registration_names = [r["registration"] for r in records] | ||
|
|
||
| # Fetch UTM parameters | ||
| utm_query = """ | ||
| SELECT | ||
| parent, | ||
| `key`, | ||
| value | ||
| FROM `tabUtm Parameters` | ||
| WHERE | ||
| parenttype = 'Zoom Webinar Registration' | ||
| AND parent IN %(parents)s | ||
| """ | ||
|
Comment on lines
+118
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for Utm Parameters doctype definition and references
echo "=== Searching for Utm Parameters references ==="
rg "Utm Parameters" --type=py --type=json -n
echo ""
echo "=== Searching for utm-related files ==="
fd "utm" -i
echo ""
echo "=== Looking for Zoom Webinar Registration doctype definition ==="
fd "zoom.*webinar.*registration" -iRepository: BuildWithHussain/zoom_integration Length of output: 810 🏁 Script executed: cat zoom_integration/zoom_integration/doctype/zoom_webinar_registration/zoom_webinar_registration.jsonRepository: BuildWithHussain/zoom_integration Length of output: 3765 🏁 Script executed: #!/bin/bash
# Search for any utm-related doctype or field definition
rg -i "utm" --type=json --type=py -n
echo ""
echo "=== Searching for all table field definitions that use Table fieldtype ==="
rg "\"Table\"" --type=json -B 5 | grep -E "(fieldname|options|Table)" | head -40Repository: BuildWithHussain/zoom_integration Length of output: 3574 🏁 Script executed: #!/bin/bash
# Find all doctype definitions
echo "=== All DocTypes in the repository ==="
find zoom_integration -name "*.json" -path "*/doctype/*" | grep -v test | xargs -I {} sh -c 'grep -l "\"doctype\": \"DocType\"" {} && echo "File: {}"' 2>/dev/null | grep -v "^File:" | sort
echo ""
echo "=== Check if Utm Parameters doctype exists ==="
find zoom_integration -name "*utm*.json" -o -name "*Utm*.json" 2>/dev/null
echo ""
echo "=== List all doctype directories ==="
ls -1 zoom_integration/zoom_integration/doctype/Repository: BuildWithHussain/zoom_integration Length of output: 903 🏁 Script executed: cat zoom_integration/zoom_integration/doctype/zoom_webinar_additional_param/zoom_webinar_additional_param.jsonRepository: BuildWithHussain/zoom_integration Length of output: 1018
The query will fail at runtime. The codebase only defines 6 DocTypes, and "Utm Parameters" is not among them. Either create this DocType as a child table for Zoom Webinar Registration, or refactor to use the existing "Zoom Webinar Additional Param" table (which already stores key-value pairs) for UTM data. 🤖 Prompt for AI Agents |
||
|
|
||
| utm_rows = frappe.db.sql( | ||
| utm_query, | ||
| {"parents": tuple(registration_names)}, | ||
| as_dict=True, | ||
| ) | ||
|
|
||
| utm_map = {} | ||
| for row in utm_rows: | ||
| utm_map.setdefault(row.parent, {})[row.key] = row.value | ||
|
|
||
| # Merge UTM data into records | ||
| for record in records: | ||
| utm = utm_map.get(record["registration"], {}) | ||
| record["utm_source"] = utm.get("utm_source", "") | ||
| record["utm_medium"] = utm.get("utm_medium", "") | ||
| record["utm_campaign"] = utm.get("utm_campaign", "") | ||
| record["utm_term"] = utm.get("utm_term", "") | ||
| record["utm_content"] = utm.get("utm_content", "") | ||
|
|
||
| # Cleanup | ||
| record.pop("registration", None) | ||
|
|
||
| return records | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Column label mismatch with actual data.
The label says "User Email" but the fieldname
userfetches theuserfield fromZoom Webinar Registration, which is a Link to the User doctype (not the email address itself). The DocType has a separateemailfield that contains the actual email.Consider either:
zwreg.emailin the SQL query if you want to display the email addressOption 1: Fix the label
{ - "label": _("User Email"), + "label": _("User"), "fieldname": "user", - "fieldtype": "Data", + "fieldtype": "Link", + "options": "User", "width": 200, },Option 2: Fetch email instead
Update the column definition:
{ "label": _("User Email"), - "fieldname": "user", + "fieldname": "email", "fieldtype": "Data", "width": 200, },And update the SQL query in
get_data():📝 Committable suggestion
🤖 Prompt for AI Agents