-
Notifications
You must be signed in to change notification settings - Fork 731
feat: allow filtering contributions and collaborations [IN-707] #3432
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
Changes from all commits
7cd4481
2a4d73a
2b8749f
8470457
8d814bb
ccf966d
ed99135
830fc28
f222cc8
b10487a
8430f7b
10ed24a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ DESCRIPTION > | |
| - `platform`: Optional string filter for source platform (e.g., 'github', 'discord', 'slack') | ||
| - `activity_type`: Optional string filter for single activity type (e.g., 'authored-commit') | ||
| - `activity_types`: Optional array of activity types (e.g., ['authored-commit', 'co-authored-commit']) | ||
| - `onlyContributions`: Optional boolean, defaults to 1 (contributions only), set to 0 for all activities | ||
| - `includeCodeContributions`: Optional boolean to include code contribution activities. Defaults to 1. Set to 0 to exclude. Inherited from activityTypes_filtered. | ||
| - `includeCollaborations`: Optional boolean to include or exclude collaboration activities. Inherited from activityTypes_filtered. | ||
| - Response: `id` (activityId), `timestamp`, `type`, `platform`, `memberId`, `organizationId`, `segmentId`. | ||
|
|
||
| NODE activities_filtered_by_timestamp_and_channel | ||
|
|
@@ -41,9 +42,7 @@ SQL > | |
| AND a.platform | ||
| = {{ String(platform, description="Filter activity platform", required=False) }} | ||
| {% end %} | ||
| {% if not defined(onlyContributions) or ( | ||
| defined(onlyContributions) and onlyContributions == 1 | ||
| ) %} AND a.isContribution {% end %} | ||
| AND (a.type, a.platform) IN (SELECT activityType, platform FROM activityTypes_filtered) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this'll break on the client part because client still uses |
||
| {% if defined(activity_type) %} | ||
| AND a.type = {{ String(activity_type, description="Filter activity type", required=False) }} | ||
| {% end %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,8 @@ DESCRIPTION > | |
| - `platform`: Optional string filter for source platform (e.g., 'github', 'discord', 'slack') | ||
| - `activity_type`: Optional string filter for single activity type (e.g., 'authored-commit') | ||
| - `activity_types`: Optional array of activity types (e.g., ['authored-commit', 'co-authored-commit']) | ||
| - `onlyContributions`: Optional boolean, defaults to 1 (contributions only), set to 0 for all activities | ||
| - `includeCodeContributions`: Optional boolean to include code contribution activities. Defaults to 1. Set to 0 to exclude. Inherited from activityTypes_filtered. | ||
| - `includeCollaborations`: Optional boolean to include or exclude collaboration activities. Inherited from activityTypes_filtered. | ||
| - `granularity`: Required string for time aggregation and period extension ('daily', 'weekly', 'monthly', 'quarterly', 'yearly') | ||
| - Response: `id` (activityId), `timestamp`, `type`, `platform`, `memberId`, `organizationId`, `segmentId`. | ||
|
|
||
|
|
@@ -57,9 +58,7 @@ SQL > | |
| AND a.platform | ||
| = {{ String(platform, description="Filter activity platform", required=False) }} | ||
| {% end %} | ||
| {% if not defined(onlyContributions) or ( | ||
| defined(onlyContributions) and onlyContributions == 1 | ||
| ) %} AND a.isContribution {% end %} | ||
| AND (a.type, a.platform) IN (SELECT activityType, platform FROM activityTypes_filtered) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this'll break on the client part because client still uses |
||
| {% if defined(activity_type) %} | ||
| AND a.type = {{ String(activity_type, description="Filter activity type", required=False) }} | ||
| {% end %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| DESCRIPTION > | ||
| - `activityTypes_filtered.pipe` allows filtering activityTypes from the respective data source. | ||
| - By default, this only returns code contribution activities (`includeCodeContributions = 1`). | ||
| - To return all activities, set `includeCodeContributions = 1`, `includeCollaborations = 1`, and `includeOtherContributions = 1`. | ||
| - Parameters: | ||
| - `includeCodeContributions`: Optional boolean to include code contribution activities. Defaults to 1. Set to 0 to exclude. | ||
| - `includeCollaborations`: Optional boolean to include or exclude collaboration activities. | ||
| - `includeOtherContributions`: Optional boolean to include other contribution activities (activities that are neither code contributions nor collaborations). | ||
| - Response: `activityType`, `platform`. | ||
| - This pipe is used by other downstream pipes as an auxiliary method of filtering data by activity types. | ||
|
|
||
| NODE activityTypes_selected | ||
| SQL > | ||
| % | ||
| WITH | ||
| {{ UInt8(includeCodeContributions, default=1) }} AS icc, | ||
| {{ UInt8(includeCollaborations, default=0) }} AS icol, | ||
| {{ UInt8(includeOtherContributions, default=0) }} AS ioc | ||
| SELECT activityType, platform | ||
| FROM activityTypes | ||
| WHERE | ||
| (icc = 1 AND isCodeContribution = 1) | ||
| OR (icol = 1 AND isCollaboration = 1) | ||
| OR (ioc = 1 AND isCodeContribution = 0 AND isCollaboration = 0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,14 @@ NODE top_member_org_copy_member_activity_count | |
| SQL > | ||
| SELECT memberId, count(*) AS activityCount | ||
| FROM activityRelations_deduplicated_cleaned_ds | ||
| WHERE (timestamp >= (now() - toIntervalYear(10))) AND (timestamp < now()) | ||
| WHERE | ||
| (timestamp >= (now() - toIntervalYear(10))) | ||
| AND (timestamp < now()) | ||
| AND (type, platform) IN ( | ||
| SELECT activityType, platform | ||
| FROM activityTypes | ||
| WHERE isCodeContribution = 1 OR isCollaboration = 1 | ||
| ) | ||
|
borfast marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Inconsistent Activity Filtering in PipeThe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we have to do it that way (with a hard-coded filter) because this is a copy pipe, and thus we won't be able to pass dynamic filters to it when making requests to an endpoint. But I'd be happy to be proven wrong. As for defaulting to including both code contributions and collaborations, that's what we want according to the PRD. |
||
| GROUP BY memberId | ||
| ORDER BY activityCount DESC | ||
| LIMIT 100 | ||
|
|
@@ -41,7 +48,15 @@ NODE top_member_org_copy_organization_activity_count | |
| SQL > | ||
| SELECT organizationId, count(*) AS activityCount | ||
| FROM activityRelations_deduplicated_cleaned_ds | ||
| WHERE (timestamp >= (now() - toIntervalYear(10))) AND (timestamp < now()) AND organizationId != '' | ||
| WHERE | ||
| (timestamp >= (now() - toIntervalYear(10))) | ||
| AND (timestamp < now()) | ||
| AND organizationId != '' | ||
| AND (type, platform) IN ( | ||
| SELECT activityType, platform | ||
| FROM activityTypes | ||
| WHERE isCodeContribution = 1 OR isCollaboration = 1 | ||
| ) | ||
| GROUP BY organizationId | ||
| ORDER BY activityCount DESC | ||
| LIMIT 100 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this'll break on the client part because client still uses
onlyContributions?