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

Insights learner csv contains zeros #89

Open
wants to merge 1 commit into
base: develop-juniper
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
18 changes: 17 additions & 1 deletion figures/edly_views/edly_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ def _get_site_daily_matrics(site):
def _get_maus(request):
maus = GetMonthlyActiveUsers()
maus.request = request

# setattr(request, 'type', 'monthly')
# setattr(request, 'start_date', '01-01-2022')
# setattr(request, 'end_date', '30-09-2022')
# setattr(request, 'include_users_data', 'include_users_data')
# setattr(maus.request, 'type', 'monthly')
# setattr(maus.request, 'start_date', '01-01-2022')
# setattr(maus.request, 'end_date', '30-09-2022')
# setattr(maus.request, 'include_users_data', 'include_users_data')


return maus.get(request)

@staticmethod
Expand Down Expand Up @@ -236,6 +247,7 @@ def get(self, request):
GET /api/edly/insights-learners
"""
query_params = request.query_params.dict()
print('query_params:', query_params)
date_format = '%d-%m-%Y'
start_date = query_params.get('start_date')
end_date = query_params.get('end_date')
Expand All @@ -253,12 +265,16 @@ def get(self, request):
)
monthly_course_completions = InsightLearnersCSV._get_monthly_course_completions(request).data
maus = InsightLearnersCSV._get_maus(request).data
print("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
print("maus:", maus)
print('monthly_course_completions:', monthly_course_completions)
print("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
context = dict()
context['required_fields'] = figures.helpers.get_required_registration_fields_for_user(
self.request.user,
site,
)
self._prepare_learners_data.delay(
self._prepare_learners_data(
site.id, maus, monthly_course_completions,
request.user.username, request.user.email,
context, site_configs, query_params
Expand Down
19 changes: 15 additions & 4 deletions figures/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def _email_report_with_attachment(recipient_email, subject, username, platform,
"""
from edly_panel_app.api.v1.helpers import email_report_with_attachment

email_report_with_attachment.delay(
email_report_with_attachment(
recipient_email, subject, username,
platform, from_address,
report_type, csv_file
Expand Down Expand Up @@ -634,6 +634,17 @@ def send_insights_summary_report(raw_data, recipient_email, username, report_typ


def send_insights_learner_report(raw_data, recipient_email, username, report_type, site_configuration):

print("--------------------------------------------------")

print("recipient_email", recipient_email)
print("username", username)
print("report_type", report_type)
print("site_configuration", site_configuration)
print("raw_data", raw_data)

print("--------------------------------------------------")

monthly_course_completions = raw_data['monthly_course_completions'].get('data', {})
all_learners_details = raw_data['all_learners_details']
site_daily_matrics = raw_data['site_daily_matrics']
Expand All @@ -651,9 +662,9 @@ def send_insights_learner_report(raw_data, recipient_email, username, report_typ
csv_report_writer.writerow(['New User Registrations (Current Month): ', curr_new_users])
csv_report_writer.writerow(['New User Registrations (Last Month): ', prev_new_users])

curr_month = datetime.datetime.now().month
curr_new_users = maus['monthly_users_count'][curr_month - 1]
prev_new_users = maus['monthly_users_count'][curr_month -2]
# curr_month = datetime.datetime.now().month
curr_new_users = maus['monthly_users_count'][-1]
prev_new_users = maus['monthly_users_count'][-2]
csv_report_writer.writerow(['Monthly Active Users (Current Month): ', curr_new_users])
csv_report_writer.writerow(['Monthly Active Users (Last Month): ', prev_new_users])

Expand Down