Skip to content

Commit

Permalink
Merge branch 'classification_user_groups-migrations-and-models' into …
Browse files Browse the repository at this point in the history
…classification-user-groups-counts
  • Loading branch information
yuenmichelle1 committed Aug 1, 2023
2 parents 6730cfa + 8c5300c commit efcd30a
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 202 deletions.
50 changes: 0 additions & 50 deletions app/controllers/user_group_classification_count_controller.rb

This file was deleted.

6 changes: 0 additions & 6 deletions app/queries/concerns/filterable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ def filter_by_user_id(scoped, user_id)
scoped.where(user_id: user_ids)
end

def filter_by_user_group_id(scoped, user_group_id)
return scoped unless user_group_id.present?

scoped.where(user_group_id: user_group_id)
end

private

def range_clause(start_date, end_date)
Expand Down
39 changes: 0 additions & 39 deletions app/queries/count_group_active_user_classifications.rb

This file was deleted.

42 changes: 0 additions & 42 deletions app/queries/count_group_classifications.rb

This file was deleted.

30 changes: 0 additions & 30 deletions app/queries/count_group_project_contributions.rb

This file was deleted.

29 changes: 0 additions & 29 deletions app/serializers/user_group_classification_counts_serializer.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

get '/comments', action: :query, controller: 'comment_count'
get '/classifications/users/:id', action: :query, controller: 'user_classification_count', constraints: { id: /\d+/ }
get '/classifications/user_groups/:id', action: :query, controller: 'user_group_classification_count', constraints: { id: /\d+/ }
get '/classifications', action: :query, controller: 'classification_count'
# get '/classifications/user_groups/:id, action: :query_by_user_group, controller: 'user_group_classification_count'
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateDailyGroupClassificationsCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateDailyGroupProjectClassificationCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateDailyGroupWorkflowClassificationCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CreateDailyGroupUserClassificationCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
Expand All @@ -6,7 +8,8 @@ class CreateDailyGroupUserClassificationCountAndTime < ActiveRecord::Migration[7
## Even though the view are very similar we cannot query from just daily_user_classification_count_and_time to get stats info of that user for that group.
## Reason being:
## A) daily_user_classification_count_and_time does not consider when a user has joined a group.
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group) [Vice versa if a user LEAVES a user group]
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group)
## [Vice versa if a user LEAVES a user group]
## B) On the flip side, we cannot query from just daily_group_classification_count_and_time_per_user, because not every user belongs to a group.
def change
execute <<~SQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
class CreateDailyGroupUserProjectCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
## We should note that this view looks very similar to the daily_user_classification_count_and_time_per_project (where the columns of that table are day, user_id, classification_count, total_session_time, project_id).
## We should note that this view looks very similar to the daily_user_classification_count_and_time_per_project
## (where the columns of that table are day, user_id, classification_count, total_session_time, project_id).
## The only difference between this view and daily_user_classification_count_and_time_per_project is that we are grouping by user_group_id (i.e. user_group_id is a column in this view).
## Even though the views are very similar we cannot query from just daily_user_classification_count_and_time_per_project to get stats info of that user for that group.
## Reason being:
## A) daily_user_classification_count_and_time_per_project does not consider WHEN a user has joined a group.
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group) [Vice versa if a user LEAVES a user group]
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group)
## [Vice versa if a user LEAVES a user group]
## B) On the flip side, we cannot query from just daily_group_classification_count_and_time_per_user_per_prject when querying for just user stats, because not every user belongs to a group.
def change
execute <<~SQL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# frozen_string_literal: true

class CreateDailyGroupUserWorkflowCountAndTime < ActiveRecord::Migration[7.0]
# we have to disable the migration transaction because creating materialized views within it is not allowed.
disable_ddl_transaction!
## We should note that this view looks very similar to the daily_user_classification_count_and_time_per_workflow (where the columns of that table are day, user_id, classification_count, total_session_time, workflow_id).
## We should note that this view looks very similar to the daily_user_classification_count_and_time_per_workflow
## (where the columns of that table are day, user_id, classification_count, total_session_time, workflow_id).
## The only difference between this view and daily_user_classification_count_and_time_per_workflow is that we are grouping by user_group_id (i.e. user_group_id is a column in this view).
## Even though the views are very similar we cannot query from just daily_user_classification_count_and_time_per_workflow to get stats info of that user for that group.
## Reason being:
## A) daily_user_classification_count_and_time_per_workflow does not consider WHEN a user has joined a group.
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group) [Vice versa if a user LEAVES a user group]
## (So if we queried for all time for the user group, the user's old classifications [when he/she/they were not part of the group] would be counted towards the user group)
## [Vice versa if a user LEAVES a user group]
## B) On the flip side, we cannot query from just daily_group_classification_count_and_time_per_user_per_workflow when querying for just user stats, because not every user belongs to a group.
def change
execute <<~SQL
Expand Down

0 comments on commit efcd30a

Please sign in to comment.