Skip to content

Feat(2632): Update organization statistics section - #2651

Open
rukundo-kevin wants to merge 2 commits into
masterfrom
2632-update-organization-statistics-section
Open

Feat(2632): Update organization statistics section#2651
rukundo-kevin wants to merge 2 commits into
masterfrom
2632-update-organization-statistics-section

Conversation

@rukundo-kevin

Copy link
Copy Markdown
Collaborator
  • add data from last entry when it loads
  • disabled dates without lessons.
  • Show a message when there is not data
image

- add data from last entry when it loads
- disabled dates without lessons.
- Show a message when there is not data
@rukundo-kevin rukundo-kevin linked an issue Jul 30, 2026 that may be closed by this pull request
private

def populate_lesson_activity
@available_lesson_dates = GroupLessonSummary.where(chapter_id: @organization.chapters).distinct.pluck(:lesson_date).sort

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is slow because you are using GroupLessonSummary when you can just query lessons since all you need are the dates. Just make sure you don't query deleted lessons.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tried this but ended up reverting it. Turns out GroupLessonSummary only counts a date if a student was actually enrolled in that group at the time — it's not just "lessons that aren't deleted" like the raw Lesson table. Querying them separately caused some orgs to default to a date with no data, and some dates were selectable but showed nothing. Pulling both from the same GroupLessonSummary relation now (just loading it once with .to_a) so they can't get out of sync.

Comment thread app/components/common_components/organization_statistics.rb Outdated
const parts = [date.getFullYear(), ('0'+(date.getMonth()+1)).slice(-2), ('0'+date.getDate()).slice(-2)];
return parts.join("-");
}
const enabledDates = this.hasEnabledDatesValue && this.enabledDatesValue.length > 0 ? new Set(this.enabledDatesValue) : null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove the length check here, if an organization had 0 lessons this would result in all dates being selectable.

Comment thread spec/features/organization_features_spec.rb Outdated
- pass number_of_lessons/total_data_points from the controller instead of computing them in the component
- fix datepicker enabling all dates when an organization has zero lessons
- keep available lesson dates and lesson summaries sourced from the same GroupLessonSummary relation, so we don't default to (or enable) a date with no actual data
- remove redundant enabled-dates feature spec
@rukundo-kevin
rukundo-kevin force-pushed the 2632-update-organization-statistics-section branch from a076c7d to 77da419 Compare August 6, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update organization statistics section

2 participants