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

Feature branch report builder (last things) #7995

Merged
merged 166 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
6b0eea9
First draft of methods_used query
luucvanderzee May 20, 2024
73b209c
Create spec (WIP)
luucvanderzee May 20, 2024
c90d132
Get spec to pass
luucvanderzee May 20, 2024
41134fc
Translations updated by CI (extract-intl)
May 20, 2024
96dce13
Create types and scaffolding widget
luucvanderzee May 21, 2024
8821b1a
Add widget to toolbox
luucvanderzee May 21, 2024
e9d78d9
Tweak spacing
luucvanderzee May 21, 2024
0a5005b
Add polls and external surveys too
luucvanderzee May 21, 2024
fa5ec32
Hook up with hook
luucvanderzee May 21, 2024
3cfaa9d
Add compared period logic
luucvanderzee May 21, 2024
8ab32f2
Translations updated by CI (extract-intl)
May 21, 2024
e34550c
Add types and render compare stuff
luucvanderzee May 21, 2024
e865bbe
Fix error
luucvanderzee May 21, 2024
4dac913
Add settings
luucvanderzee May 21, 2024
8ce197c
Translations updated by CI (extract-intl)
May 21, 2024
79fb18b
Remove hardcoded 30 days
luucvanderzee May 21, 2024
1015e5a
Add participation query (WIP)
luucvanderzee May 21, 2024
3288be3
Last days -> previous days
luucvanderzee May 22, 2024
6c44462
Merge branch 'TAN-1527-methods-used-widget' into TAN-1900-participati…
luucvanderzee May 22, 2024
5e40716
Translations updated by CI (extract-intl)
May 22, 2024
c0f3b2d
Translations updated by CI (extract-intl)
May 22, 2024
7d10bae
Add spec for time series
luucvanderzee May 22, 2024
a5e9d6d
Add spec for compared period
luucvanderzee May 22, 2024
dc8a9bd
_
luucvanderzee May 22, 2024
03a37ca
Add useParticipation hook
luucvanderzee May 22, 2024
163bab1
Implement time series parsing
luucvanderzee May 22, 2024
2f63da8
Scaffold hook and layouts
luucvanderzee May 22, 2024
4040a5d
Translations updated by CI (extract-intl)
May 22, 2024
ba6268a
Add to toolbox
luucvanderzee May 22, 2024
ba943f9
Fix bug in parsing
luucvanderzee May 22, 2024
ca50a5e
_
luucvanderzee May 22, 2024
e639d69
Add statistics
luucvanderzee May 22, 2024
357b514
Add basic settings
luucvanderzee May 22, 2024
1b16f96
Fix wide layout
luucvanderzee May 22, 2024
d38d90a
Implement narrow layout
luucvanderzee May 22, 2024
fcae34f
Use participationTypes to hide stuff in FE
luucvanderzee May 22, 2024
d28416f
Add checkboxes to settings to toggle visiblity participation types
luucvanderzee May 22, 2024
028065b
Add tooltip
luucvanderzee May 22, 2024
24b53fb
Deprecate old timeline widgets
luucvanderzee May 22, 2024
a50f915
_
luucvanderzee May 23, 2024
6d2582f
Merge branch 'master' into TAN-1527-methods-used-widget
luucvanderzee May 23, 2024
9d4e7af
Merge branch 'TAN-1527-methods-used-widget' into TAN-1900-participati…
luucvanderzee May 23, 2024
bbc19ba
Merge branch 'TAN-1900-participation-widget' into TAN-1525-projects-w…
luucvanderzee May 23, 2024
620a041
Store participationTypes as hash instead of array
luucvanderzee May 24, 2024
316ab5e
Also fix widget compare period stuff in settings here
luucvanderzee May 24, 2024
59fa206
_
luucvanderzee May 24, 2024
4079268
_
luucvanderzee May 24, 2024
013d101
Fix projects query and spec
luucvanderzee May 24, 2024
8a04234
Create hook and types
luucvanderzee May 24, 2024
197fa42
_
luucvanderzee May 24, 2024
e1adf08
Merge branch 'TAN-1900-participation-widget' into TAN-1525-projects-w…
luucvanderzee May 24, 2024
6a0eeb6
Translations updated by CI (extract-intl)
May 24, 2024
1737380
Fix open ended phase issue
luucvanderzee May 24, 2024
8801c4c
ProjectsCard scaffolding
luucvanderzee May 24, 2024
c1642ec
_
luucvanderzee May 24, 2024
29ae5ba
Handle phases with open ends
luucvanderzee May 24, 2024
ffcdf01
Make sure projects without phases are filtered out
luucvanderzee May 24, 2024
01baa30
Fix open ended phase issue
luucvanderzee May 24, 2024
6aee367
_
luucvanderzee May 24, 2024
c246075
Add project images to query response
luucvanderzee May 27, 2024
fd65cfa
Merge branch 'master' into TAN-1527-methods-used-widget
luucvanderzee May 27, 2024
560d909
Merge branch 'TAN-1527-methods-used-widget' into TAN-1900-participati…
luucvanderzee May 27, 2024
da2e06f
Merge branch 'TAN-1900-participation-widget' into TAN-1525-projects-w…
luucvanderzee May 27, 2024
a14cef4
Translations updated by CI (extract-intl)
May 27, 2024
2733928
Add FE types for project_images in query response
luucvanderzee May 27, 2024
11054de
_
luucvanderzee May 27, 2024
8079deb
Fix specs
luucvanderzee May 27, 2024
0848a3c
_
luucvanderzee May 27, 2024
1f84008
Add start and end date to card
luucvanderzee May 27, 2024
de5b727
Added stats
luucvanderzee May 27, 2024
32048fb
_
luucvanderzee May 27, 2024
0ac9436
Derive project label logic
luucvanderzee May 27, 2024
039b64c
Finish project row
luucvanderzee May 27, 2024
dfea417
Tweak spacing
luucvanderzee May 27, 2024
950353e
Rename Projects -> Published projects
luucvanderzee May 27, 2024
098205b
Improve test naming
luucvanderzee May 27, 2024
daf720b
Translations updated by CI (extract-intl)
May 27, 2024
e14ddba
Fix FE unit tesT
luucvanderzee May 27, 2024
516a6bd
Add settings
luucvanderzee May 27, 2024
4e2a0e0
Fix BE test
luucvanderzee May 27, 2024
c4f8ed0
Use sort to sort ids before checking
luucvanderzee May 27, 2024
55a2a7d
Create template
luucvanderzee May 28, 2024
9a05ae8
Add radio button for strategic report template
luucvanderzee May 28, 2024
a4b7f54
Add date range picker
luucvanderzee May 28, 2024
837b213
Only show strategic template radio option for super admins
luucvanderzee May 28, 2024
ce51ee4
Write start and end date params to URL from modal
luucvanderzee May 28, 2024
2b20112
_
luucvanderzee May 28, 2024
536fd9f
Also use bold text in project report for top stat stuff
luucvanderzee May 28, 2024
c613839
_
luucvanderzee May 28, 2024
7a65eb2
_
luucvanderzee May 28, 2024
7f6f238
Fix report crashing
luucvanderzee May 28, 2024
274ea67
Shut up horrible react-intl errors
luucvanderzee May 28, 2024
6e54a7f
_
luucvanderzee May 28, 2024
31ebc95
Add registrations and participants widgets
luucvanderzee May 28, 2024
b0adc31
Add compared period
luucvanderzee May 28, 2024
89668cf
Inclusion indicators header and placeholder
luucvanderzee May 28, 2024
8043ef0
_
luucvanderzee May 28, 2024
f737471
Add demographics
luucvanderzee May 28, 2024
c4bd10e
Add projects widget
luucvanderzee May 28, 2024
36f0f92
Add Methods used widget
luucvanderzee May 28, 2024
55fbdc5
Translations updated by CI (extract-intl)
May 28, 2024
3d8515a
Add participation widget
luucvanderzee May 28, 2024
113c68a
Add participants statistic to top stats stuff
luucvanderzee May 28, 2024
78e8dd3
Add projects stat too
luucvanderzee May 28, 2024
5665eb6
Translations updated by CI (extract-intl)
May 28, 2024
988f8b8
Rename strategic -> platform
luucvanderzee May 29, 2024
2dc7114
Translations updated by CI (extract-intl)
May 29, 2024
fbebf0a
Add fallback image to projects in projects widget
luucvanderzee May 29, 2024
f252a54
Add autosave for platform reports
luucvanderzee May 29, 2024
d78a165
Dates in settings: just use full days, not specific seconds and stuff
luucvanderzee May 29, 2024
347bdeb
Merge pull request #8050 from CitizenLabDotCo/TAN-1819-date-behavior
luucvanderzee May 29, 2024
989ed22
Remove unnecessary rewind_sequences calls
luucvanderzee May 29, 2024
c0267e4
Replace create dimension type by populate types
luucvanderzee May 29, 2024
fae5da9
Improve destructuring stuff
luucvanderzee May 29, 2024
10b39ca
Improve naming in active users query
luucvanderzee May 29, 2024
26ba1f1
Improve naming registrations query
luucvanderzee May 29, 2024
8177a08
Fix comments by time spec
luucvanderzee May 29, 2024
594ca40
_
luucvanderzee May 29, 2024
6cfd9dc
Remove duplication in visitors_spec
luucvanderzee May 29, 2024
f4b54a2
_
luucvanderzee May 29, 2024
a9a400e
Reuse more for widget settings
luucvanderzee May 29, 2024
e961eed
_
luucvanderzee May 29, 2024
c342304
Reduce unnecessary boxes Wide layouts
luucvanderzee May 29, 2024
9202f98
Simplify narrow layouts
luucvanderzee May 29, 2024
4621cb4
Update banner explanation
luucvanderzee May 31, 2024
df3671c
Refactor visitors statistics
luucvanderzee May 31, 2024
1d284e6
Translations updated by CI (extract-intl)
May 31, 2024
c8dbcbe
Replace 'active users' by 'participants' in BE
luucvanderzee May 31, 2024
9bced7d
Replace 'active users' by 'participants' in FE
luucvanderzee May 31, 2024
0a29d92
Translations updated by CI (extract-intl)
May 31, 2024
add4b30
Skip flaky date test
luucvanderzee Jun 3, 2024
f1af9f1
Remove flakiness participants timeline widget
luucvanderzee Jun 3, 2024
04bdb63
Improve query according to Adrien's suggestion
luucvanderzee Jun 3, 2024
3643d3c
Extract STALENESS_PERIOD variable
luucvanderzee Jun 3, 2024
f01c6e3
Filter out non-published projects in BE
luucvanderzee Jun 3, 2024
525bddd
Project period copy
luucvanderzee Jun 3, 2024
c2f0b2d
Time boundary parser changes
luucvanderzee Jun 3, 2024
c444ba3
Translations updated by CI (extract-intl)
Jun 3, 2024
b5077bc
Merge branch 'TAN-1525-projects-widget' into TAN-1529-strategic-repor…
luucvanderzee Jun 3, 2024
1ef8599
[TAN-1641] Remove remaining references to "active users"
adessy Jun 4, 2024
2404f6a
_
luucvanderzee Jun 4, 2024
32bf22c
Merge branch 'TAN-1525-projects-widget' into TAN-1529-strategic-repor…
luucvanderzee Jun 4, 2024
0e6aa92
Make design methods used widget look a bit nicer on A4
luucvanderzee Jun 4, 2024
ddd0fc0
Replace lorem ipsum by generic copy
luucvanderzee Jun 4, 2024
3ff4f1a
Quarters projects -> projects
luucvanderzee Jun 4, 2024
14693a3
_
luucvanderzee Jun 4, 2024
307fd36
Move magic numbers
luucvanderzee Jun 4, 2024
464b13a
Fix formatting
luucvanderzee Jun 4, 2024
f1a47eb
_
luucvanderzee Jun 4, 2024
8faf7e3
Create a project report -> Create a report
luucvanderzee Jun 4, 2024
83b219b
Translations updated by CI (extract-intl)
Jun 4, 2024
fa7ed9f
Remove console override
luucvanderzee Jun 4, 2024
1006722
Merge branch 'TAN-1529-strategic-report-template' into TAN-1902-rando…
luucvanderzee Jun 4, 2024
54c1e73
Merge branch 'TAN-1902-random-fixes' into TAN-1641-participants-cleanup
luucvanderzee Jun 4, 2024
2ef6294
Merge pull request #8080 from CitizenLabDotCo/TAN-1641-participants-c…
luucvanderzee Jun 4, 2024
953caa8
Merge pull request #8053 from CitizenLabDotCo/TAN-1902-random-fixes
luucvanderzee Jun 4, 2024
8904685
Merge pull request #8040 from CitizenLabDotCo/TAN-1529-strategic-repo…
luucvanderzee Jun 4, 2024
06e152b
Merge pull request #7999 from CitizenLabDotCo/TAN-1525-projects-widget
luucvanderzee Jun 4, 2024
5cb338e
Merge pull request #7996 from CitizenLabDotCo/TAN-1900-participation-…
luucvanderzee Jun 4, 2024
00ef8d0
Merge branch 'master' into TAN-1527-methods-used-widget
luucvanderzee Jun 4, 2024
ee69b91
Fix flaky registrations_spec
luucvanderzee Jun 4, 2024
705630a
Remove unnecessary copy
luucvanderzee Jun 4, 2024
c7abfb4
Translations updated by CI (extract-intl)
Jun 4, 2024
494212f
Remove old obsolete e2e tests
luucvanderzee Jun 4, 2024
99d8385
Fix phase report test
luucvanderzee Jun 4, 2024
57cb8c1
_
luucvanderzee Jun 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'rspec_api_documentation/dsl'

resource 'Analytics - FactParticipations' do
explanation 'Queries to summarise participations/active users.'
explanation 'Queries to summarise participations.'

before do
header 'Content-Type', 'application/json'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ReportBuilder
class Queries::Analytics::ActiveUsers < Queries::Analytics::Base
def active_users_query(start_at, end_at, project_id, apply_visitor_filter: false)
class Queries::Analytics::Participants < Queries::Analytics::Base
def participants_query(start_at, end_at, project_id, apply_visitor_filter: false)
{
fact: 'participation',
filters: {
Expand Down Expand Up @@ -51,43 +51,43 @@ def query(
}
}

active_users_whole_period_query = active_users_query(start_at, end_at, project_id)
participants_whole_period_query = participants_query(start_at, end_at, project_id)
visitors_whole_period_query = visitors_query(start_at, end_at, project_id)

# We request the active user count again,
# We request the participants count again,
# but this time we filter by has_visits = true
# This is so that we can calculate a more accurate
# conversion rate on the FE, where we only compare
# visitors (i.e. people that accepted cookies)
# to active users that also accepted cookies
active_visitor_users_whole_period_query = active_users_query(
# to participants that also accepted cookies
participants_who_accepted_cookies_whole_period_query = participants_query(
start_at, end_at, project_id, apply_visitor_filter: true
)

queries = [
time_series_query,
active_users_whole_period_query,
participants_whole_period_query,
visitors_whole_period_query,
active_visitor_users_whole_period_query
participants_who_accepted_cookies_whole_period_query
]

if compare_start_at.present? && compare_end_at.present?
active_users_compared_period_query = active_users_query(compare_start_at, compare_end_at, project_id)
participants_compared_period_query = participants_query(compare_start_at, compare_end_at, project_id)
visitors_compared_period_query = visitors_query(compare_start_at, compare_end_at, project_id)

# We request the active user count again,
# We request the participants count again,
# but this time we filter by has_visits = true
# This is so that we can calculate a more accurate
# conversion rate on the FE, where we only compare
# visitors (i.e. people that accepted cookies)
# to active users that also accepted cookies
active_visitor_users_compared_period_query = active_users_query(
# to participants that also accepted cookies
participants_who_accepted_cookies_compared_period_query = participants_query(
compare_start_at, compare_end_at, project_id, apply_visitor_filter: true
)

queries << active_users_compared_period_query
queries << participants_compared_period_query
queries << visitors_compared_period_query
queries << active_visitor_users_compared_period_query
queries << participants_who_accepted_cookies_compared_period_query
end

queries
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
module ReportBuilder
class Queries::Analytics::Participation < Queries::Analytics::Base
protected

def query(
start_at: nil,
end_at: nil,
project_id: nil,
resolution: nil,
compare_start_at: nil,
compare_end_at: nil,
**_other_props
)
# First, the time series
inputs_time_series = {
fact: 'post',
filters: {
**date_filter('dimension_date_created', start_at, end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': %w[idea initiative],
publication_status: 'published'
},
groups: "dimension_date_created.#{interval(resolution)}",
aggregations: {
all: 'count',
'dimension_date_created.date': 'first'
}
}

comments_time_series = {
fact: 'participation',
filters: {
**date_filter('dimension_date_created', start_at, end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': 'comment',
'dimension_type.parent': %w[idea initiative]
},
groups: "dimension_date_created.#{interval(resolution)}",
aggregations: {
all: 'count',
'dimension_date_created.date': 'first'
}
}

baskets_time_series = {
fact: 'participation',
filters: {
**date_filter('dimension_date_created', start_at, end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': 'basket'
},
groups: "dimension_date_created.#{interval(resolution)}",
aggregations: {
all: 'count',
'dimension_date_created.date': 'first'
}
}

queries = [
inputs_time_series,
comments_time_series,
baskets_time_series
]

# We will derive the totals of the whole period in the FE, based on the time series

# Second, if necessary, the comparisons
if compare_start_at.present? && compare_end_at.present?
inputs_compared_period = {
fact: 'post',
filters: {
**date_filter('dimension_date_created', compare_start_at, compare_end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': %w[idea initiative],
publication_status: 'published'
},
aggregations: {
all: 'count'
}
}

comments_compared_period = {
fact: 'participation',
filters: {
**date_filter('dimension_date_created', compare_start_at, compare_end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': 'comment',
'dimension_type.parent': %w[idea initiative]
},
aggregations: {
all: 'count'
}
}

baskets_compared_period = {
fact: 'participation',
filters: {
**date_filter('dimension_date_created', start_at, end_at),
**project_filter('dimension_project_id', project_id),
'dimension_type.name': 'basket'
},
aggregations: {
all: 'count'
}
}

queries << inputs_compared_period
queries << comments_compared_period
queries << baskets_compared_period
end

queries
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,32 @@ def query(
registrations_whole_period_query = registrations_query(start_at, end_at)
visitors_whole_period_query = visitors_query(start_at, end_at)

# Similar to active_users.rb, we request the registrations another
# Similar to participants.rb, we request the registrations another
# time, but this time we filter by has_visits = true
registrations_visitors_whole_period_query = registrations_query(
registrations_who_accepted_cookies_whole_period_query = registrations_query(
start_at, end_at, apply_visitor_filter: true
)

queries = [
time_series_query,
registrations_whole_period_query,
visitors_whole_period_query,
registrations_visitors_whole_period_query
registrations_who_accepted_cookies_whole_period_query
]

if compare_start_at.present? && compare_end_at.present?
registrations_compared_period_query = registrations_query(compare_start_at, compare_end_at)
visitors_compared_period_query = visitors_query(compare_start_at, compare_end_at)

# Similar to active_users.rb, we request the registrations another
# Similar to participants.rb, we request the registrations another
# time, but this time we filter by has_visits = true
registrations_visitors_compared_period_query = registrations_query(
registrations_who_accepted_cookies_compared_period_query = registrations_query(
compare_start_at, compare_end_at, apply_visitor_filter: true
)

queries << registrations_compared_period_query
queries << visitors_compared_period_query
queries << registrations_visitors_compared_period_query
queries << registrations_who_accepted_cookies_compared_period_query
end

queries
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module ReportBuilder
class Queries::MethodsUsed < ReportBuilder::Queries::Base
def run_query(
start_at: nil,
end_at: nil,
compare_start_at: nil,
compare_end_at: nil,
**_other_props
)
start_date, end_date = TimeBoundariesParser.new(start_at, end_at).parse

json_response = {
count_per_method: get_methods_used_in_overlapping_phases(
start_date,
end_date
)
}

if compare_start_at.present? && compare_end_at.present?
json_response[:count_per_method_compared_period] = get_methods_used_in_overlapping_phases(
compare_start_at, compare_end_at
)
end

json_response
end

def get_methods_used_in_overlapping_phases(start_date, end_date)
non_overlapping_phase_ids = Phase.where('end_at <= ? OR start_at >= ?', start_date, end_date).select(:id)

Phase
.where.not(id: non_overlapping_phase_ids)
.group(:participation_method)
.count
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module ReportBuilder
class Queries::Projects < ReportBuilder::Queries::Base
def run_query(start_at: nil, end_at: nil, **_other_props)
start_date, end_date = TimeBoundariesParser.new(start_at, end_at).parse

overlapping_project_ids = Phase
.select(:project_id)
.where("(start_at, coalesce(end_at, 'infinity'::DATE)) OVERLAPS (?, ?)", start_date, end_date)

overlapping_projects = Project
.joins(:admin_publication)
.where(id: overlapping_project_ids)
.where(admin_publication: { publication_status: 'published' })

periods = Phase
.select(
:project_id,
'min(start_at) as start_at',
'max(start_at) as last_phase_start_at',
'CASE WHEN count(end_at) = count(*) THEN max(end_at) ELSE NULL END as end_at'
)
.where(project_id: overlapping_project_ids)
.group(:project_id)
.to_h do |period|
[
period.project_id,
period.slice(:start_at, :last_phase_start_at, :end_at)
]
end

project_images_hash = ProjectImage
.where(project_id: overlapping_projects)
.to_h { |project_image| [project_image.id, serialize(project_image, ::WebApi::V1::ImageSerializer)] }

participants = Analytics::FactParticipation
.where(dimension_project_id: overlapping_project_ids)
.group(:dimension_project_id)
.select('COUNT(DISTINCT participant_id) as participants_count, dimension_project_id')
.to_h { |participant| [participant.dimension_project_id, participant.participants_count] }

{
projects: serialize(overlapping_projects, ::WebApi::V1::ProjectSerializer),
project_images: project_images_hash,
periods: periods,
participants: participants
}
end

private

def serialize(entity, serializer)
serializer.new(entity, params: { current_user: @current_user }).serializable_hash[:data]
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ class QueryRepository
'ReactionsByTimeWidget' => Queries::Analytics::ReactionsByTime,
'CommentsByTimeWidget' => Queries::Analytics::CommentsByTime,
'PostsByTimeWidget' => Queries::Analytics::PostsByTime,
'ActiveUsersWidget' => Queries::Analytics::ActiveUsers,
'ParticipantsWidget' => Queries::Analytics::Participants,
'VisitorsWidget' => Queries::Analytics::Visitors,
'VisitorsTrafficSourcesWidget' => Queries::Analytics::TrafficSources,
'SurveyQuestionResultWidget' => Queries::SurveyQuestionResult,
'MostReactedIdeasWidget' => Queries::MostReactedIdeas,
'SingleIdeaWidget' => Queries::SingleIdea,
'DemographicsWidget' => Queries::Demographics,
'RegistrationsWidget' => Queries::Analytics::Registrations
'RegistrationsWidget' => Queries::Analytics::Registrations,
'MethodsUsedWidget' => Queries::MethodsUsed,
'ParticipationWidget' => Queries::Analytics::Participation,
'ProjectsWidget' => Queries::Projects
}.freeze

def initialize(current_user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
let(:date) { Date.new(2022, 9, 1) }
let(:idea) do
create(:dimension_date, date: date)
create(:dimension_type, name: 'idea', parent: 'post')

create(:idea, created_at: date)
end

before do
create(:dimension_type, name: 'comment', parent: 'idea')
Analytics::PopulateDimensionsService.populate_types
create(:comment, created_at: date, post: idea)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe ReportBuilder::Queries::Analytics::ActiveUsers do
RSpec.describe ReportBuilder::Queries::Analytics::Participants do
subject(:query) { described_class.new(build(:user)) }

describe '#run_query' do
Expand All @@ -13,11 +13,10 @@

@dimension_date_sept = create(:dimension_date, date: @date_september)
@dimension_date_oct = create(:dimension_date, date: @date_october)
create(:dimension_type, name: 'idea', parent: 'post')
create(:dimension_type, name: 'comment', parent: 'idea')
Analytics::PopulateDimensionsService.populate_types
end

it 'returns active users' do
it 'returns participants' do
project = create(:single_phase_ideation_project)
create(:idea, created_at: @date_september, project: project)

Expand Down Expand Up @@ -99,7 +98,7 @@
)
end

it 'returns active users in compared period' do
it 'returns participants in compared period' do
project = create(:project)
pp1, pp2, pp3, pp4 = create_list(:user, 4)

Expand Down
Loading