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

TAN-3815 - Community monitor backend #10365

Open
wants to merge 62 commits into
base: master
Choose a base branch
from

Conversation

jamesspeake
Copy link
Contributor

@jamesspeake jamesspeake commented Feb 18, 2025

Changes in a nutshell:

  • hidden project - flagged using both internal_role: 'community_monitor and a new field hidden: true on project
    • this field is then used to hide the project from lists of projects in various places
  • exclude emails/followers/notifications being created for hidden projects
  • new feature flag community_monitor which also stores the project ID for this project
  • hidden project has a single phase with a new community_monitor_survey participation method which inherits from native survey
  • new endpoint to get/create this project/phase
  • as community_monitor_survey currently inherits most things from native_survey I have removed phase.native_survey? everywhere and used phase.pmethod.supports_survey_form? - in line with us wanting to delegate as much as possible to the participation method
    • This is also added as an attribute on the phase serializer so the front-end can use it (separate PR)

Changelog

Technical

  • Added APIs, participation method and model changes for new community monitor survey
  • Prevented native_surveys from creating idea followers

@jamesspeake jamesspeake marked this pull request as ready for review February 19, 2025 08:16
@jamesspeake jamesspeake added this to the Community Monitor milestone Feb 21, 2025
@@ -390,8 +388,9 @@ def set_presentation_mode
self.presentation_mode ||= 'card'
end

def validate_voting
Factory.instance.voting_method_for(self).validate_phase
# Delegate any rules specific to a method to the participation method itself
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this more generic so any participation method can now implement it's own validation rules

@@ -0,0 +1,5 @@
class AddHiddenToProjects < ActiveRecord::Migration[7.0]
def change
add_column :projects, :hidden, :boolean, default: false, null: false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not add an index here as for booleans I don't think it often gets used

Comment on lines 114 to 119

# Check the last field is a page
if @participation_method.supports_pages_in_form? && fields.last[:input_type] != 'page'
errors["#{fields.length - 1}"] = { structure: [{ error: "Last field must be of type 'page'" }] }
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated, but noticed this logic was missing

@@ -22,7 +22,7 @@ def participation_possible
subquery = projects_with_active_phase(subquery)
.joins('INNER JOIN phases AS active_phases ON active_phases.project_id = projects.id')
.where.not(phases: { participation_method: 'information' })
.select('projects.*, projects.created_at AS projects_created_at, projects.id AS projects_id')
.select('projects.created_at AS projects_created_at, projects.id AS projects_id')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This turned out to be unneeded as it was double returning all the fields

@@ -25,7 +25,7 @@ def clean_assignees_for_project!(project)
end

def automatically_assigned_idea_assignee(idea)
return if idea.participation_method_on_creation.instance_of?(ParticipationMethod::NativeSurvey)
return unless idea.participation_method_on_creation.automatically_assign_idea?
Copy link
Contributor Author

@jamesspeake jamesspeake Feb 27, 2025

Choose a reason for hiding this comment

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

Changed so that we can check multiple participation methods

Comment on lines +54 to +57
def form_logic_enabled?
false
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not actually used at the moment, but will be used for community monitor

input_type: 'page',
page_layout: 'default'
),
start_page_field(custom_form),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now shared between methods. Suspect there may be some overlap here with Edwin's work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mainly a copy of native survey, but differences are likely to be introduced later

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.

2 participants