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

Added column showing number of recently active users to projets under OrganizationAdmin #591

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

why-not-try-calmer
Copy link
Contributor

… OrganizationAdmin

@why-not-try-calmer why-not-try-calmer added the enhancement New feature or request label Mar 21, 2023
@duke-nyuki
Copy link
Collaborator

@suricactus suricactus changed the title Added column showing number of recently active users to projets under… Added column showing number of recently active users to projets under OrganizationAdmin Mar 23, 2023
Comment on lines 1037 to 1042
@admin.display(description=_("Active users (last 90 days)"))
def active_users(self, instance) -> int:
now = datetime.now()
three_months_ago = now - timedelta(days=90)
return len(list(instance.active_users(now, three_months_ago)))

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually you can use org.current_subscription.active_users_count, which will do it for the last billing period, if the subscription was active and probably raise? otherwise. If the latter case we better return None, which makes the admin show -.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And one remark, look at the page performance. If it get's 100%+ slower, probably it should not be a column in the List view, but readonly field in the edit view.

@why-not-try-calmer why-not-try-calmer force-pushed the QF-2603_show_active_users_under_orga branch from bd9ced8 to 612feb3 Compare March 23, 2023 15:41
@suricactus suricactus merged commit 1d97d4c into master Mar 23, 2023
@suricactus suricactus deleted the QF-2603_show_active_users_under_orga branch March 23, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants