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

[8381] add unregistered participants field to project insights to account fo… #2830

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

goapunk
Copy link
Contributor

@goapunk goapunk commented Nov 4, 2024

…r the

new feature in the poll module which allows participating without account

Tasks

  • PR name contains story or task reference
  • Documentation (docs and inline)
  • Tests (including n+1 and django_assert_num_queries where applicable)
  • Changelog

depends on liqd/adhocracy4#1688

@goapunk goapunk changed the title add unregistered participants field to project insights to account fo… [8381] add unregistered participants field to project insights to account fo… Nov 4, 2024
@goapunk goapunk changed the title [8381] add unregistered participants field to project insights to account fo… WIP: [8381] add unregistered participants field to project insights to account fo… Nov 4, 2024
@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch from 8d086c5 to 3481b63 Compare November 4, 2024 17:21
apps/projects/signals.py Outdated Show resolved Hide resolved
@goapunk goapunk requested a review from m4ra November 4, 2024 17:32
apps/projects/signals.py Outdated Show resolved Hide resolved
Copy link
Contributor

@m4ra m4ra left a comment

Choose a reason for hiding this comment

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

I suggest to keep this PR on-hold and proceed with the fix in a new PR. See my inline comments.

@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch 2 times, most recently from 5ed20f2 to 63ad043 Compare November 6, 2024 15:33
@goapunk
Copy link
Contributor Author

goapunk commented Nov 6, 2024

I've updated this with the signal solution to compare now

@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch from 63ad043 to 554836c Compare November 6, 2024 15:35
@goapunk goapunk requested a review from m4ra November 7, 2024 12:36
@goapunk goapunk changed the title WIP: [8381] add unregistered participants field to project insights to account fo… [8381] add unregistered participants field to project insights to account fo… Nov 7, 2024
Copy link
Contributor

@m4ra m4ra left a comment

Choose a reason for hiding this comment

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

Looks good. Can you update the insights docs?

@m4ra
Copy link
Contributor

m4ra commented Nov 12, 2024

@goapunk there is an error also with the signals import, tests failing

@goapunk
Copy link
Contributor Author

goapunk commented Nov 12, 2024

Looks good. Can you update the insights docs?

@m4ra will do, the signal error is because it needs the a4 pr merged first

@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch from 554836c to 1aabe86 Compare November 12, 2024 16:31
@goapunk goapunk requested a review from m4ra November 12, 2024 16:37
Copy link
Contributor

@m4ra m4ra left a comment

Choose a reason for hiding this comment

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

Some clarifications on how we count active participants

(_("active participants"), insight.active_participants.count()),
(
_("active participants"),
insight.active_participants.count() + insight.unregistered_participants,
Copy link
Contributor

Choose a reason for hiding this comment

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

here active participants are the sum of both registered and unregistered. But when a poll is submitted by an unregistered user, the active participants are not increased, only the unregistered ones. See my comment below in the signal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

active_participants is a m2m relation to the user model, so we can't increase it for unregistered users, that's why I added the unregistered_participants field. And we combine both fields here to reflect the total count of participants (maybe somewhat confusingly still called "active participants").

apps/projects/signals.py Show resolved Hide resolved
if creator:
insight.active_participants.add(creator.id)
else:
insight.unregistered_participants += 1
Copy link
Contributor

Choose a reason for hiding this comment

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

here, shouldn't we also increment the active_participants?

Copy link
Contributor

@m4ra m4ra left a comment

Choose a reason for hiding this comment

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

thanx for clarifying, LGTM

@m4ra
Copy link
Contributor

m4ra commented Nov 19, 2024

@goapunk can you update the a4 hash, and add a changelog? I have approved already, so please go ahead and merge once you are done.

@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch from 1aabe86 to d92e768 Compare November 20, 2024 09:40
@goapunk goapunk enabled auto-merge (rebase) November 20, 2024 09:41
@m4ra
Copy link
Contributor

m4ra commented Nov 21, 2024

@goapunk looks like the project-insight model needs to have the active_participants field as nullable. See the test failing.

@goapunk goapunk disabled auto-merge November 21, 2024 16:37
insight.active_participants.add(*ids)
# content from unregistered users doesn't have a creator but a content_id
if model_field_exists(obj.model, "content_id"):
content_ids = set(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I now added more generic way of counting the unregistered participants, what do you think ? If that's fine I'd squash this commit and merge it afterwards

@goapunk goapunk requested a review from m4ra November 21, 2024 16:40
@m4ra
Copy link
Contributor

m4ra commented Nov 27, 2024

@goapunk LGTM. Go ahead with commits squashing and merge

…r the

new feature in the poll module which allows participating without
account
@goapunk goapunk force-pushed the jd-2024-11-poll-insights branch from 8722bfe to 8e78892 Compare November 27, 2024 13:13
@goapunk goapunk enabled auto-merge (rebase) November 27, 2024 13:13
@goapunk goapunk merged commit cd5fbb2 into main Nov 27, 2024
2 checks passed
@goapunk goapunk deleted the jd-2024-11-poll-insights branch November 27, 2024 13:21
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.

3 participants