From 6b7518344826c25b1094507d45eb3e36cf5eaecb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:34:02 +0000 Subject: [PATCH 1/8] Bump puma from 5.6.7 to 5.6.8 in /server Bumps [puma](https://github.com/puma/puma) from 5.6.7 to 5.6.8. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v5.6.7...v5.6.8) --- updated-dependencies: - dependency-name: puma dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- server/Gemfile | 2 +- server/Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/Gemfile b/server/Gemfile index ef52f1618..508a3c387 100644 --- a/server/Gemfile +++ b/server/Gemfile @@ -8,7 +8,7 @@ gem 'rails', '~> 6.1', '>= 6.1.3.1' # Use postgresql as the database for Active Record gem 'pg', '~> 1.1' # Use Puma as the app server -gem 'puma', '5.6.7' +gem 'puma', '5.6.8' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker diff --git a/server/Gemfile.lock b/server/Gemfile.lock index 973bcf9a4..f4d301516 100644 --- a/server/Gemfile.lock +++ b/server/Gemfile.lock @@ -247,7 +247,7 @@ GEM net-smtp (0.3.3) net-protocol net-ssh (7.2.0) - nio4r (2.5.9) + nio4r (2.7.0) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) nokogiri (1.15.4-x86_64-darwin) @@ -295,7 +295,7 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (5.0.3) - puma (5.6.7) + puma (5.6.8) nio4r (~> 2.0) raabro (1.4.0) racc (1.7.1) @@ -515,7 +515,7 @@ DEPENDENCIES pg (~> 1.1) pry pry-rails - puma (= 5.6.7) + puma (= 5.6.8) rack-cors (~> 1.1.1) rack-mini-profiler (~> 2.0) rails (~> 6.1, >= 6.1.3.1) From cb7f9d83219dcd7ad51c096c9916679711d9212d Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Mon, 8 Jan 2024 15:10:58 -0600 Subject: [PATCH 2/8] handle null case in timeago pipe --- client/src/app/core/pipes/timeago-formatter.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/app/core/pipes/timeago-formatter.ts b/client/src/app/core/pipes/timeago-formatter.ts index 230f5340b..f52639ade 100644 --- a/client/src/app/core/pipes/timeago-formatter.ts +++ b/client/src/app/core/pipes/timeago-formatter.ts @@ -1,4 +1,4 @@ -import { Injectable, Pipe } from '@angular/core' +import { Pipe } from '@angular/core' const SECONDS_IN_MINUTE = 60 const SECONDS_IN_HOUR = SECONDS_IN_MINUTE * 60 @@ -24,14 +24,16 @@ const withYearFormatter = new Intl.DateTimeFormat('en-US', withYearOptions) @Pipe({ name: 'timeAgo', - pure: true + pure: true, }) export class CivicTimeagoFormatter { transform(input: number | string): string { + if (!input) return '--' + let then: number - if (typeof input =='number') { + if (typeof input == 'number') { then = input - } else { + } else { then = Date.parse(input) } From a8946ea00bb0ec0c06b55b7dcb2f9ca41dbdc62d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:43:17 +0000 Subject: [PATCH 3/8] Bump follow-redirects from 1.14.9 to 1.15.4 in /server Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.9 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.9...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- server/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/yarn.lock b/server/yarn.lock index 9eb211ed9..97154a3ec 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -3277,9 +3277,9 @@ flush-write-stream@^1.0.0: readable-stream "^2.3.6" follow-redirects@^1.0.0: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== for-in@^1.0.2: version "1.0.2" From f9adf59061740559c543ee828f7842fd5949d2a1 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Tue, 9 Jan 2024 18:19:02 -0600 Subject: [PATCH 4/8] Move last action timestamp caching to activities. Add column for Orgs --- .../organizations-table.component.html | 2 +- .../organizations-table.query.gql | 4 +--- .../users-table/users-table.component.html | 4 ++-- .../users/users-table/users-table.query.gql | 2 +- .../src/app/generated/civic.apollo-helpers.ts | 16 +++++++------- client/src/app/generated/civic.apollo.ts | 22 +++++++++---------- client/src/app/generated/server.model.graphql | 8 +++---- client/src/app/generated/server.schema.json | 16 +++++++------- .../app/graphql/resolvers/top_level_users.rb | 2 +- .../types/entities/organization_type.rb | 6 +---- .../app/graphql/types/entities/user_type.rb | 2 +- server/app/models/activities/base.rb | 11 ++++++++++ server/app/models/event.rb | 6 ----- ...110000025_add_last_org_action_timestamp.rb | 8 +++++++ 14 files changed, 57 insertions(+), 52 deletions(-) create mode 100644 server/db/migrate/20240110000025_add_last_org_action_timestamp.rb diff --git a/client/src/app/components/organizations/organizations-table/organizations-table.component.html b/client/src/app/components/organizations/organizations-table/organizations-table.component.html index 9763c4654..ed58b633f 100644 --- a/client/src/app/components/organizations/organizations-table/organizations-table.component.html +++ b/client/src/app/components/organizations/organizations-table/organizations-table.component.html @@ -108,7 +108,7 @@ - {{ organization.mostRecentEvent?.createdAt | timeAgo }} + {{ organization.mostRecentActivityTimestamp | timeAgo }} diff --git a/client/src/app/components/organizations/organizations-table/organizations-table.query.gql b/client/src/app/components/organizations/organizations-table/organizations-table.query.gql index 9b98c2f9d..8e7846936 100644 --- a/client/src/app/components/organizations/organizations-table/organizations-table.query.gql +++ b/client/src/app/components/organizations/organizations-table/organizations-table.query.gql @@ -44,9 +44,7 @@ fragment OrganizationBrowseTableRowFields on Organization { name id } - mostRecentEvent { - createdAt - } + mostRecentActivityTimestamp # orgStatsHash @include(if: $cardView) { # comments # revisions diff --git a/client/src/app/components/users/users-table/users-table.component.html b/client/src/app/components/users/users-table/users-table.component.html index f5550d727..9a2aa207c 100644 --- a/client/src/app/components/users/users-table/users-table.component.html +++ b/client/src/app/components/users/users-table/users-table.component.html @@ -176,8 +176,8 @@ - {{ user.mostRecentActionTimestamp | timeAgo }} + *ngIf="user.mostRecentActivityTimestamp; else eventElse"> + {{ user.mostRecentActivityTimestamp | timeAgo }} -- diff --git a/client/src/app/components/users/users-table/users-table.query.gql b/client/src/app/components/users/users-table/users-table.query.gql index d6f0f6ea0..80f74fb00 100644 --- a/client/src/app/components/users/users-table/users-table.query.gql +++ b/client/src/app/components/users/users-table/users-table.query.gql @@ -48,5 +48,5 @@ fragment UserBrowseTableRowFields on User { revisions } profileImagePath(size: 64) - mostRecentActionTimestamp + mostRecentActivityTimestamp } diff --git a/client/src/app/generated/civic.apollo-helpers.ts b/client/src/app/generated/civic.apollo-helpers.ts index 1d51976a6..754380352 100644 --- a/client/src/app/generated/civic.apollo-helpers.ts +++ b/client/src/app/generated/civic.apollo-helpers.ts @@ -883,7 +883,7 @@ export type GeneEdgeFieldPolicy = { cursor?: FieldPolicy | FieldReadFunction, node?: FieldPolicy | FieldReadFunction }; -export type LeaderboardOrganizationKeySpecifier = ('actionCount' | 'description' | 'eventCount' | 'events' | 'id' | 'memberCount' | 'members' | 'mostRecentEvent' | 'name' | 'orgAndSuborgsStatsHash' | 'orgStatsHash' | 'profileImagePath' | 'rank' | 'ranks' | 'subGroups' | 'url' | LeaderboardOrganizationKeySpecifier)[]; +export type LeaderboardOrganizationKeySpecifier = ('actionCount' | 'description' | 'eventCount' | 'events' | 'id' | 'memberCount' | 'members' | 'mostRecentActivityTimestamp' | 'name' | 'orgAndSuborgsStatsHash' | 'orgStatsHash' | 'profileImagePath' | 'rank' | 'ranks' | 'subGroups' | 'url' | LeaderboardOrganizationKeySpecifier)[]; export type LeaderboardOrganizationFieldPolicy = { actionCount?: FieldPolicy | FieldReadFunction, description?: FieldPolicy | FieldReadFunction, @@ -892,7 +892,7 @@ export type LeaderboardOrganizationFieldPolicy = { id?: FieldPolicy | FieldReadFunction, memberCount?: FieldPolicy | FieldReadFunction, members?: FieldPolicy | FieldReadFunction, - mostRecentEvent?: FieldPolicy | FieldReadFunction, + mostRecentActivityTimestamp?: FieldPolicy | FieldReadFunction, name?: FieldPolicy | FieldReadFunction, orgAndSuborgsStatsHash?: FieldPolicy | FieldReadFunction, orgStatsHash?: FieldPolicy | FieldReadFunction, @@ -920,7 +920,7 @@ export type LeaderboardRankFieldPolicy = { actionCount?: FieldPolicy | FieldReadFunction, rank?: FieldPolicy | FieldReadFunction }; -export type LeaderboardUserKeySpecifier = ('actionCount' | 'areaOfExpertise' | 'bio' | 'country' | 'displayName' | 'email' | 'events' | 'facebookProfile' | 'id' | 'linkedinProfile' | 'mostRecentActionTimestamp' | 'mostRecentConflictOfInterestStatement' | 'mostRecentEvent' | 'mostRecentOrganizationId' | 'name' | 'notifications' | 'orcid' | 'organizations' | 'profileImagePath' | 'rank' | 'ranks' | 'role' | 'statsHash' | 'twitterHandle' | 'url' | 'username' | LeaderboardUserKeySpecifier)[]; +export type LeaderboardUserKeySpecifier = ('actionCount' | 'areaOfExpertise' | 'bio' | 'country' | 'displayName' | 'email' | 'events' | 'facebookProfile' | 'id' | 'linkedinProfile' | 'mostRecentActivityTimestamp' | 'mostRecentConflictOfInterestStatement' | 'mostRecentEvent' | 'mostRecentOrganizationId' | 'name' | 'notifications' | 'orcid' | 'organizations' | 'profileImagePath' | 'rank' | 'ranks' | 'role' | 'statsHash' | 'twitterHandle' | 'url' | 'username' | LeaderboardUserKeySpecifier)[]; export type LeaderboardUserFieldPolicy = { actionCount?: FieldPolicy | FieldReadFunction, areaOfExpertise?: FieldPolicy | FieldReadFunction, @@ -932,7 +932,7 @@ export type LeaderboardUserFieldPolicy = { facebookProfile?: FieldPolicy | FieldReadFunction, id?: FieldPolicy | FieldReadFunction, linkedinProfile?: FieldPolicy | FieldReadFunction, - mostRecentActionTimestamp?: FieldPolicy | FieldReadFunction, + mostRecentActivityTimestamp?: FieldPolicy | FieldReadFunction, mostRecentConflictOfInterestStatement?: FieldPolicy | FieldReadFunction, mostRecentEvent?: FieldPolicy | FieldReadFunction, mostRecentOrganizationId?: FieldPolicy | FieldReadFunction, @@ -1284,7 +1284,7 @@ export type ObjectFieldDiffFieldPolicy = { removedObjects?: FieldPolicy | FieldReadFunction, suggestedObjects?: FieldPolicy | FieldReadFunction }; -export type OrganizationKeySpecifier = ('description' | 'eventCount' | 'events' | 'id' | 'memberCount' | 'members' | 'mostRecentEvent' | 'name' | 'orgAndSuborgsStatsHash' | 'orgStatsHash' | 'profileImagePath' | 'ranks' | 'subGroups' | 'url' | OrganizationKeySpecifier)[]; +export type OrganizationKeySpecifier = ('description' | 'eventCount' | 'events' | 'id' | 'memberCount' | 'members' | 'mostRecentActivityTimestamp' | 'name' | 'orgAndSuborgsStatsHash' | 'orgStatsHash' | 'profileImagePath' | 'ranks' | 'subGroups' | 'url' | OrganizationKeySpecifier)[]; export type OrganizationFieldPolicy = { description?: FieldPolicy | FieldReadFunction, eventCount?: FieldPolicy | FieldReadFunction, @@ -1292,7 +1292,7 @@ export type OrganizationFieldPolicy = { id?: FieldPolicy | FieldReadFunction, memberCount?: FieldPolicy | FieldReadFunction, members?: FieldPolicy | FieldReadFunction, - mostRecentEvent?: FieldPolicy | FieldReadFunction, + mostRecentActivityTimestamp?: FieldPolicy | FieldReadFunction, name?: FieldPolicy | FieldReadFunction, orgAndSuborgsStatsHash?: FieldPolicy | FieldReadFunction, orgStatsHash?: FieldPolicy | FieldReadFunction, @@ -1844,7 +1844,7 @@ export type UpdateSourceSuggestionStatusPayloadFieldPolicy = { clientMutationId?: FieldPolicy | FieldReadFunction, sourceSuggestion?: FieldPolicy | FieldReadFunction }; -export type UserKeySpecifier = ('areaOfExpertise' | 'bio' | 'country' | 'displayName' | 'email' | 'events' | 'facebookProfile' | 'id' | 'linkedinProfile' | 'mostRecentActionTimestamp' | 'mostRecentConflictOfInterestStatement' | 'mostRecentEvent' | 'mostRecentOrg' | 'mostRecentOrganizationId' | 'name' | 'notifications' | 'orcid' | 'organizations' | 'profileImagePath' | 'ranks' | 'role' | 'statsHash' | 'twitterHandle' | 'url' | 'username' | UserKeySpecifier)[]; +export type UserKeySpecifier = ('areaOfExpertise' | 'bio' | 'country' | 'displayName' | 'email' | 'events' | 'facebookProfile' | 'id' | 'linkedinProfile' | 'mostRecentActivityTimestamp' | 'mostRecentConflictOfInterestStatement' | 'mostRecentEvent' | 'mostRecentOrg' | 'mostRecentOrganizationId' | 'name' | 'notifications' | 'orcid' | 'organizations' | 'profileImagePath' | 'ranks' | 'role' | 'statsHash' | 'twitterHandle' | 'url' | 'username' | UserKeySpecifier)[]; export type UserFieldPolicy = { areaOfExpertise?: FieldPolicy | FieldReadFunction, bio?: FieldPolicy | FieldReadFunction, @@ -1855,7 +1855,7 @@ export type UserFieldPolicy = { facebookProfile?: FieldPolicy | FieldReadFunction, id?: FieldPolicy | FieldReadFunction, linkedinProfile?: FieldPolicy | FieldReadFunction, - mostRecentActionTimestamp?: FieldPolicy | FieldReadFunction, + mostRecentActivityTimestamp?: FieldPolicy | FieldReadFunction, mostRecentConflictOfInterestStatement?: FieldPolicy | FieldReadFunction, mostRecentEvent?: FieldPolicy | FieldReadFunction, mostRecentOrg?: FieldPolicy | FieldReadFunction, diff --git a/client/src/app/generated/civic.apollo.ts b/client/src/app/generated/civic.apollo.ts index a4ea50b3a..05495c80b 100644 --- a/client/src/app/generated/civic.apollo.ts +++ b/client/src/app/generated/civic.apollo.ts @@ -2130,7 +2130,7 @@ export type LeaderboardOrganization = { id: Scalars['Int']; memberCount: Scalars['Int']; members: UserConnection; - mostRecentEvent?: Maybe; + mostRecentActivityTimestamp?: Maybe; name: Scalars['String']; orgAndSuborgsStatsHash: Stats; orgStatsHash: Stats; @@ -2204,7 +2204,7 @@ export type LeaderboardUser = { facebookProfile?: Maybe; id: Scalars['Int']; linkedinProfile?: Maybe; - mostRecentActionTimestamp?: Maybe; + mostRecentActivityTimestamp?: Maybe; mostRecentConflictOfInterestStatement?: Maybe; mostRecentEvent?: Maybe; mostRecentOrganizationId?: Maybe; @@ -3167,7 +3167,7 @@ export type Organization = { id: Scalars['Int']; memberCount: Scalars['Int']; members: UserConnection; - mostRecentEvent?: Maybe; + mostRecentActivityTimestamp?: Maybe; name: Scalars['String']; orgAndSuborgsStatsHash: Stats; orgStatsHash: Stats; @@ -5270,7 +5270,7 @@ export type User = { facebookProfile?: Maybe; id: Scalars['Int']; linkedinProfile?: Maybe; - mostRecentActionTimestamp?: Maybe; + mostRecentActivityTimestamp?: Maybe; mostRecentConflictOfInterestStatement?: Maybe; mostRecentEvent?: Maybe; mostRecentOrg?: Maybe; @@ -6277,9 +6277,9 @@ export type OrganizationsBrowseQueryVariables = Exact<{ }>; -export type OrganizationsBrowseQuery = { __typename: 'Query', organizations: { __typename: 'OrganizationConnection', totalCount: number, pageInfo: { __typename: 'PageInfo', hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | undefined, endCursor?: string | undefined }, edges: Array<{ __typename: 'OrganizationEdge', cursor: string, node?: { __typename: 'Organization', id: number, name: string, description: string, url: string, memberCount: number, eventCount: number, subGroups: Array<{ __typename: 'Organization', name: string, id: number }>, mostRecentEvent?: { __typename: 'Event', createdAt: any } | undefined } | undefined }> } }; +export type OrganizationsBrowseQuery = { __typename: 'Query', organizations: { __typename: 'OrganizationConnection', totalCount: number, pageInfo: { __typename: 'PageInfo', hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | undefined, endCursor?: string | undefined }, edges: Array<{ __typename: 'OrganizationEdge', cursor: string, node?: { __typename: 'Organization', id: number, name: string, description: string, url: string, memberCount: number, eventCount: number, mostRecentActivityTimestamp?: any | undefined, subGroups: Array<{ __typename: 'Organization', name: string, id: number }> } | undefined }> } }; -export type OrganizationBrowseTableRowFieldsFragment = { __typename: 'Organization', id: number, name: string, description: string, url: string, memberCount: number, eventCount: number, subGroups: Array<{ __typename: 'Organization', name: string, id: number }>, mostRecentEvent?: { __typename: 'Event', createdAt: any } | undefined }; +export type OrganizationBrowseTableRowFieldsFragment = { __typename: 'Organization', id: number, name: string, description: string, url: string, memberCount: number, eventCount: number, mostRecentActivityTimestamp?: any | undefined, subGroups: Array<{ __typename: 'Organization', name: string, id: number }> }; export type PhenotypePopoverQueryVariables = Exact<{ phenotypeId: Scalars['Int']; @@ -6541,9 +6541,9 @@ export type UsersBrowseQueryVariables = Exact<{ }>; -export type UsersBrowseQuery = { __typename: 'Query', users: { __typename: 'UserConnection', totalCount: number, pageInfo: { __typename: 'PageInfo', endCursor?: string | undefined, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | undefined }, edges: Array<{ __typename: 'UserEdge', cursor: string, node?: { __typename: 'User', id: number, name?: string | undefined, displayName: string, role: UserRole, profileImagePath?: string | undefined, mostRecentActionTimestamp?: any | undefined, organizations: Array<{ __typename: 'Organization', id: number, name: string }>, statsHash: { __typename: 'Stats', submittedEvidenceItems: number, revisions: number } } | undefined }> } }; +export type UsersBrowseQuery = { __typename: 'Query', users: { __typename: 'UserConnection', totalCount: number, pageInfo: { __typename: 'PageInfo', endCursor?: string | undefined, hasNextPage: boolean, hasPreviousPage: boolean, startCursor?: string | undefined }, edges: Array<{ __typename: 'UserEdge', cursor: string, node?: { __typename: 'User', id: number, name?: string | undefined, displayName: string, role: UserRole, profileImagePath?: string | undefined, mostRecentActivityTimestamp?: any | undefined, organizations: Array<{ __typename: 'Organization', id: number, name: string }>, statsHash: { __typename: 'Stats', submittedEvidenceItems: number, revisions: number } } | undefined }> } }; -export type UserBrowseTableRowFieldsFragment = { __typename: 'User', id: number, name?: string | undefined, displayName: string, role: UserRole, profileImagePath?: string | undefined, mostRecentActionTimestamp?: any | undefined, organizations: Array<{ __typename: 'Organization', id: number, name: string }>, statsHash: { __typename: 'Stats', submittedEvidenceItems: number, revisions: number } }; +export type UserBrowseTableRowFieldsFragment = { __typename: 'User', id: number, name?: string | undefined, displayName: string, role: UserRole, profileImagePath?: string | undefined, mostRecentActivityTimestamp?: any | undefined, organizations: Array<{ __typename: 'Organization', id: number, name: string }>, statsHash: { __typename: 'Stats', submittedEvidenceItems: number, revisions: number } }; export type VariantGroupPopoverQueryVariables = Exact<{ variantGroupId: Scalars['Int']; @@ -8333,9 +8333,7 @@ export const OrganizationBrowseTableRowFieldsFragmentDoc = gql` name id } - mostRecentEvent { - createdAt - } + mostRecentActivityTimestamp } `; export const PhenotypeBrowseTableRowFieldsFragmentDoc = gql` @@ -8621,7 +8619,7 @@ export const UserBrowseTableRowFieldsFragmentDoc = gql` revisions } profileImagePath(size: 64) - mostRecentActionTimestamp + mostRecentActivityTimestamp } `; export const VariantGroupPopoverFieldsFragmentDoc = gql` diff --git a/client/src/app/generated/server.model.graphql b/client/src/app/generated/server.model.graphql index 5d3661992..b328ca97a 100644 --- a/client/src/app/generated/server.model.graphql +++ b/client/src/app/generated/server.model.graphql @@ -3506,7 +3506,7 @@ type LeaderboardOrganization { """ last: Int ): UserConnection! - mostRecentEvent: Event + mostRecentActivityTimestamp: ISO8601DateTime name: String! orgAndSuborgsStatsHash: Stats! orgStatsHash: Stats! @@ -3598,7 +3598,7 @@ type LeaderboardUser { facebookProfile: String id: Int! linkedinProfile: String - mostRecentActionTimestamp: ISO8601DateTime + mostRecentActivityTimestamp: ISO8601DateTime mostRecentConflictOfInterestStatement: Coi mostRecentEvent: Event mostRecentOrganizationId: Int @@ -5044,7 +5044,7 @@ type Organization { """ last: Int ): UserConnection! - mostRecentEvent: Event + mostRecentActivityTimestamp: ISO8601DateTime name: String! orgAndSuborgsStatsHash: Stats! orgStatsHash: Stats! @@ -8483,7 +8483,7 @@ type User { facebookProfile: String id: Int! linkedinProfile: String - mostRecentActionTimestamp: ISO8601DateTime + mostRecentActivityTimestamp: ISO8601DateTime mostRecentConflictOfInterestStatement: Coi mostRecentEvent: Event mostRecentOrganizationId: Int diff --git a/client/src/app/generated/server.schema.json b/client/src/app/generated/server.schema.json index 649d76a90..f97c2fc12 100644 --- a/client/src/app/generated/server.schema.json +++ b/client/src/app/generated/server.schema.json @@ -16980,12 +16980,12 @@ "deprecationReason": null }, { - "name": "mostRecentEvent", + "name": "mostRecentActivityTimestamp", "description": null, "args": [], "type": { - "kind": "OBJECT", - "name": "Event", + "kind": "SCALAR", + "name": "ISO8601DateTime", "ofType": null }, "isDeprecated": false, @@ -17522,7 +17522,7 @@ "deprecationReason": null }, { - "name": "mostRecentActionTimestamp", + "name": "mostRecentActivityTimestamp", "description": null, "args": [], "type": { @@ -24358,12 +24358,12 @@ "deprecationReason": null }, { - "name": "mostRecentEvent", + "name": "mostRecentActivityTimestamp", "description": null, "args": [], "type": { - "kind": "OBJECT", - "name": "Event", + "kind": "SCALAR", + "name": "ISO8601DateTime", "ofType": null }, "isDeprecated": false, @@ -39093,7 +39093,7 @@ "deprecationReason": null }, { - "name": "mostRecentActionTimestamp", + "name": "mostRecentActivityTimestamp", "description": null, "args": [], "type": { diff --git a/server/app/graphql/resolvers/top_level_users.rb b/server/app/graphql/resolvers/top_level_users.rb index 147ca9689..874e8ce4d 100644 --- a/server/app/graphql/resolvers/top_level_users.rb +++ b/server/app/graphql/resolvers/top_level_users.rb @@ -41,7 +41,7 @@ class Resolvers::TopLevelUsers < GraphQL::Schema::Resolver when 'ROLE' scope.reorder("users.role #{value.direction}") when 'LAST_ACTION' - scope.reorder("users.most_recent_action_timestamp #{value.direction} NULLS LAST") + scope.reorder("users.most_recent_activity_timestamp #{value.direction} NULLS LAST") end end end diff --git a/server/app/graphql/types/entities/organization_type.rb b/server/app/graphql/types/entities/organization_type.rb index 5e52cd39c..0bc3b6a80 100644 --- a/server/app/graphql/types/entities/organization_type.rb +++ b/server/app/graphql/types/entities/organization_type.rb @@ -9,7 +9,7 @@ class OrganizationType < Types::BaseObject field :org_stats_hash, Types::StatsType, null: false field :org_and_suborgs_stats_hash, Types::StatsType, null: false field :members, Types::Entities::UserType.connection_type, null: false - field :most_recent_event, Types::Entities::EventType, null: true + field :most_recent_activity_timestamp, GraphQL::Types::ISO8601DateTime, null: true field :member_count, Int, null: false field :event_count, Int, null: false field :ranks, Types::Entities::RanksType, null: false @@ -29,10 +29,6 @@ def events Loaders::AssociationLoader.for(Organization, :events).load(object) end - def most_recent_event - Loaders::AssociationLoader.for(Organization, :most_recent_event).load(object) - end - def sub_groups Loaders::AssociationLoader.for(Organization, :groups).load(object) end diff --git a/server/app/graphql/types/entities/user_type.rb b/server/app/graphql/types/entities/user_type.rb index 49354b6fa..a9a3ac31c 100644 --- a/server/app/graphql/types/entities/user_type.rb +++ b/server/app/graphql/types/entities/user_type.rb @@ -18,7 +18,7 @@ class UserType < Types::BaseObject field :stats_hash, Types::StatsType, null: false field :most_recent_conflict_of_interest_statement, Types::Entities::CoiType, null: true field :most_recent_event, Types::Entities::EventType, null: true - field :most_recent_action_timestamp, GraphQL::Types::ISO8601DateTime, null: true + field :most_recent_activity_timestamp, GraphQL::Types::ISO8601DateTime, null: true field :most_recent_organization_id, Int, null: true field :ranks, Types::Entities::RanksType, null: false diff --git a/server/app/models/activities/base.rb b/server/app/models/activities/base.rb index ded6f7d47..f445d9095 100644 --- a/server/app/models/activities/base.rb +++ b/server/app/models/activities/base.rb @@ -18,6 +18,7 @@ def execute link_activity set_verbiage after_completed + update_timestamps end def create_activity @@ -50,5 +51,15 @@ def set_verbiage def after_completed #no op end + + def update_timestamps + activity.user.most_recent_activity_timestamp = activity.created_at + activity.user.save!(validate: false) + + if activity.organization_id.present? + activity.organization.most_recent_activity_timestamp = activity.created_at + activity.organization.save!(validate: false) + end + end end end diff --git a/server/app/models/event.rb b/server/app/models/event.rb index 33f9945aa..7b5f7bf10 100644 --- a/server/app/models/event.rb +++ b/server/app/models/event.rb @@ -12,7 +12,6 @@ class Event < ActiveRecord::Base validate :subject_is_subscribable before_create :capture_user_role - after_create :update_user_timestamp after_commit :queue_feed_updates, on: [:create] after_commit :update_most_recent_org, on: [:create] @@ -23,11 +22,6 @@ def capture_user_role self.user_role = self.originating_user.role end - def update_user_timestamp - self.originating_user.most_recent_action_timestamp = self.created_at - self.originating_user.save - end - private def subject_is_subscribable unless subject.is_a?(Subscribable) diff --git a/server/db/migrate/20240110000025_add_last_org_action_timestamp.rb b/server/db/migrate/20240110000025_add_last_org_action_timestamp.rb new file mode 100644 index 000000000..4d2b7f09a --- /dev/null +++ b/server/db/migrate/20240110000025_add_last_org_action_timestamp.rb @@ -0,0 +1,8 @@ +class AddLastOrgActionTimestamp < ActiveRecord::Migration[6.1] + def change + add_column :organizations, :most_recent_activity_timestamp, :datetime, null: true + add_index :organizations, :most_recent_activity_timestamp + + rename_column :users, :most_recent_action_timestamp, :most_recent_activity_timestamp + end +end From 9ff05a4918f90a5fee55a79b22ec039bdb1d908a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:55:15 +0000 Subject: [PATCH 5/8] Bump follow-redirects from 1.15.2 to 1.15.4 in /client Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.2...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- client/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/yarn.lock b/client/yarn.lock index fcff02111..54bbb7efb 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -5302,9 +5302,9 @@ flat@^5.0.2: integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== follow-redirects@^1.0.0, follow-redirects@^1.15.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== for-each@^0.3.3: version "0.3.3" From a35dd0de35f2faacca5f9bae5246cb0e25f4a5a6 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 10 Jan 2024 10:24:20 -0600 Subject: [PATCH 6/8] check in schema file --- server/db/schema.rb | 265 +++++++++++++++++++++++++++++--------------- 1 file changed, 177 insertions(+), 88 deletions(-) diff --git a/server/db/schema.rb b/server/db/schema.rb index 2a3b35054..fdeef1290 100644 --- a/server/db/schema.rb +++ b/server/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_11_22_204214) do +ActiveRecord::Schema.define(version: 2024_01_10_000025) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -442,6 +442,40 @@ t.index ["therapy_id", "evidence_item_id"], name: "idx_therapy_eid_bridge_table" end + create_table "feature_aliases", force: :cascade do |t| + t.text "name", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["name"], name: "index_feature_aliases_on_name" + end + + create_table "feature_aliases_features", force: :cascade do |t| + t.bigint "feature_id", null: false + t.bigint "feature_alias_id", null: false + t.index ["feature_alias_id"], name: "index_feature_aliases_features_on_feature_alias_id" + t.index ["feature_id", "feature_alias_id"], name: "idx_feature_alias" + t.index ["feature_id"], name: "index_feature_aliases_features_on_feature_id" + end + + create_table "features", force: :cascade do |t| + t.text "name", null: false + t.text "description" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.string "feature_instance_type", null: false + t.bigint "feature_instance_id", null: false + t.boolean "flagged", default: false, null: false + t.text "full_name" + t.index ["feature_instance_type", "feature_instance_id"], name: "index_features_on_feature_instance" + end + + create_table "features_sources", force: :cascade do |t| + t.bigint "source_id", null: false + t.bigint "feature_id", null: false + t.index ["feature_id"], name: "index_features_sources_on_feature_id" + t.index ["source_id"], name: "index_features_sources_on_source_id" + end + create_table "flags", id: :serial, force: :cascade do |t| t.integer "flagging_user_id" t.integer "resolving_user_id" @@ -581,6 +615,8 @@ t.integer "parent_id" t.datetime "created_at", precision: 6 t.datetime "updated_at", precision: 6 + t.datetime "most_recent_activity_timestamp" + t.index ["most_recent_activity_timestamp"], name: "index_organizations_on_most_recent_activity_timestamp" end create_table "phenotypes", id: :serial, force: :cascade do |t| @@ -678,7 +714,7 @@ t.integer "source_type", null: false t.integer "asco_abstract_id" t.text "asco_presenter" - t.boolean "fully_curated", default: false, null: false + t.text "status", default: "fully_curated", null: false t.index ["asco_abstract_id"], name: "index_sources_on_asco_abstract_id" t.index ["asco_presenter"], name: "index_sources_on_asco_presenter" t.index ["citation_id"], name: "index_sources_on_citation_id" @@ -778,11 +814,11 @@ t.boolean "signup_complete" t.integer "country_id" t.integer "most_recent_organization_id" - t.datetime "most_recent_action_timestamp" + t.datetime "most_recent_activity_timestamp" t.index ["country_id"], name: "index_users_on_country_id" t.index ["deleted"], name: "index_users_on_deleted" t.index ["last_seen_at"], name: "index_users_on_last_seen_at" - t.index ["most_recent_action_timestamp"], name: "index_users_on_most_recent_action_timestamp" + t.index ["most_recent_activity_timestamp"], name: "index_users_on_most_recent_activity_timestamp" t.index ["role"], name: "index_users_on_role" end @@ -868,11 +904,13 @@ t.integer "deprecation_reason" t.integer "deprecation_comment_id" t.text "open_cravat_url" + t.bigint "feature_id" t.index "lower((name)::text) varchar_pattern_ops", name: "idx_case_insensitive_variant_name" t.index "lower((name)::text)", name: "variant_lower_name_idx" t.index ["chromosome"], name: "index_variants_on_chromosome" t.index ["chromosome2"], name: "index_variants_on_chromosome2" t.index ["deleted"], name: "index_variants_on_deleted" + t.index ["feature_id"], name: "index_variants_on_feature_id" t.index ["gene_id"], name: "index_variants_on_gene_id" t.index ["name"], name: "index_variants_on_name" t.index ["reference_bases"], name: "index_variants_on_reference_bases" @@ -930,6 +968,10 @@ add_foreign_key "evidence_items_phenotypes", "phenotypes" add_foreign_key "evidence_items_therapies", "evidence_items" add_foreign_key "evidence_items_therapies", "therapies" + add_foreign_key "feature_aliases_features", "feature_aliases" + add_foreign_key "feature_aliases_features", "features" + add_foreign_key "features_sources", "features" + add_foreign_key "features_sources", "sources" add_foreign_key "gene_aliases_genes", "gene_aliases" add_foreign_key "gene_aliases_genes", "genes" add_foreign_key "genes_sources", "genes" @@ -960,6 +1002,7 @@ add_foreign_key "variant_group_variants", "variant_groups" add_foreign_key "variant_group_variants", "variants" add_foreign_key "variants", "comments", column: "deprecation_comment_id" + add_foreign_key "variants", "features" add_foreign_key "variants", "genes" add_foreign_key "variants", "genes", column: "secondary_gene_id" add_foreign_key "variants", "molecular_profiles", column: "single_variant_molecular_profile_id" @@ -985,47 +1028,6 @@ JOIN evidence_items ei ON (((mp.id = ei.molecular_profile_id) AND (ei.deleted = false)))) GROUP BY mp.id; SQL - create_view "molecular_profile_browse_table_rows", materialized: true, sql_definition: <<-SQL - SELECT outer_mps.id, - outer_mps.name, - count(DISTINCT evidence_items.id) AS evidence_item_count, - array_agg(DISTINCT molecular_profile_aliases.name ORDER BY molecular_profile_aliases.name) AS alias_names, - json_agg(DISTINCT jsonb_build_object('name', genes.name, 'id', genes.id)) FILTER (WHERE (genes.name IS NOT NULL)) AS genes, - json_agg(DISTINCT jsonb_build_object('name', variants.name, 'id', variants.id)) FILTER (WHERE (variants.name IS NOT NULL)) AS variants, - json_agg(DISTINCT jsonb_build_object('name', diseases.name, 'id', diseases.id, 'total', disease_count.total)) FILTER (WHERE (diseases.name IS NOT NULL)) AS diseases, - json_agg(DISTINCT jsonb_build_object('name', therapies.name, 'id', therapies.id, 'total', therapy_count.total)) FILTER (WHERE (therapies.name IS NOT NULL)) AS therapies, - count(DISTINCT assertions.id) AS assertion_count, - count(DISTINCT variants.id) AS variant_count, - outer_mps.evidence_score - FROM ((((((((((((molecular_profiles outer_mps - LEFT JOIN evidence_items ON ((evidence_items.molecular_profile_id = outer_mps.id))) - JOIN molecular_profiles_variants ON ((outer_mps.id = molecular_profiles_variants.molecular_profile_id))) - JOIN variants ON ((molecular_profiles_variants.variant_id = variants.id))) - JOIN genes ON ((genes.id = variants.gene_id))) - LEFT JOIN diseases ON ((diseases.id = evidence_items.disease_id))) - LEFT JOIN evidence_items_therapies ON ((evidence_items_therapies.evidence_item_id = evidence_items.id))) - LEFT JOIN therapies ON ((therapies.id = evidence_items_therapies.therapy_id))) - LEFT JOIN assertions ON ((assertions.molecular_profile_id = outer_mps.id))) - LEFT JOIN molecular_profile_aliases_molecular_profiles ON ((molecular_profile_aliases_molecular_profiles.molecular_profile_id = outer_mps.id))) - LEFT JOIN molecular_profile_aliases ON ((molecular_profile_aliases.id = molecular_profile_aliases_molecular_profiles.molecular_profile_alias_id))) - LEFT JOIN LATERAL ( SELECT therapies_1.id AS therapy_id, - count(DISTINCT evidence_items_1.id) AS total - FROM ((evidence_items evidence_items_1 - JOIN evidence_items_therapies evidence_items_therapies_1 ON ((evidence_items_therapies_1.evidence_item_id = evidence_items_1.id))) - JOIN therapies therapies_1 ON ((therapies_1.id = evidence_items_therapies_1.therapy_id))) - WHERE (evidence_items_1.molecular_profile_id = outer_mps.id) - GROUP BY therapies_1.id) therapy_count ON ((therapies.id = therapy_count.therapy_id))) - LEFT JOIN LATERAL ( SELECT diseases_1.id AS disease_id, - count(DISTINCT evidence_items_1.id) AS total - FROM (evidence_items evidence_items_1 - JOIN diseases diseases_1 ON ((diseases_1.id = evidence_items_1.disease_id))) - WHERE (evidence_items_1.molecular_profile_id = outer_mps.id) - GROUP BY diseases_1.id) disease_count ON ((diseases.id = disease_count.disease_id))) - WHERE (outer_mps.deprecated = false) - GROUP BY outer_mps.id, outer_mps.name, outer_mps.evidence_score; - SQL - add_index "molecular_profile_browse_table_rows", ["id"], name: "index_molecular_profile_browse_table_rows_on_id", unique: true - create_view "variant_group_browse_table_rows", materialized: true, sql_definition: <<-SQL SELECT variant_groups.id, variant_groups.name, @@ -1114,16 +1116,98 @@ SQL add_index "source_browse_table_rows", ["id"], name: "index_source_browse_table_rows_on_id", unique: true + create_view "evidence_items_by_types", sql_definition: <<-SQL + SELECT mp.id AS molecular_profile_id, + sum( + CASE + WHEN (ei.evidence_type = 0) THEN 1 + ELSE 0 + END) AS diagnostic_count, + sum( + CASE + WHEN (ei.evidence_type = 1) THEN 1 + ELSE 0 + END) AS prognostic_count, + sum( + CASE + WHEN (ei.evidence_type = 2) THEN 1 + ELSE 0 + END) AS predictive_count, + sum( + CASE + WHEN (ei.evidence_type = 3) THEN 1 + ELSE 0 + END) AS predisposing_count, + sum( + CASE + WHEN (ei.evidence_type = 4) THEN 1 + ELSE 0 + END) AS functional_count, + sum( + CASE + WHEN (ei.evidence_type = 5) THEN 1 + ELSE 0 + END) AS oncogenic_count + FROM (molecular_profiles mp + JOIN evidence_items ei ON (((mp.id = ei.molecular_profile_id) AND (ei.deleted = false) AND ((ei.status)::text <> 'rejected'::text)))) + GROUP BY mp.id; + SQL + create_view "feature_browse_table_rows", materialized: true, sql_definition: <<-SQL + SELECT outer_features.id, + outer_features.name, + outer_features.flagged, + array_agg(DISTINCT feature_aliases.name ORDER BY feature_aliases.name) AS alias_names, + json_agg(DISTINCT jsonb_build_object('name', diseases.name, 'id', diseases.id, 'total', disease_count.total)) FILTER (WHERE (diseases.name IS NOT NULL)) AS diseases, + json_agg(DISTINCT jsonb_build_object('name', therapies.name, 'id', therapies.id, 'total', therapy_count.total)) FILTER (WHERE (therapies.name IS NOT NULL)) AS therapies, + count(DISTINCT variants.id) AS variant_count, + count(DISTINCT evidence_items.id) AS evidence_item_count, + count(DISTINCT assertions.id) AS assertion_count, + count(DISTINCT molecular_profiles.id) AS molecular_profile_count + FROM ((((((((((((features outer_features + LEFT JOIN feature_aliases_features ON ((feature_aliases_features.feature_id = outer_features.id))) + LEFT JOIN feature_aliases ON ((feature_aliases.id = feature_aliases_features.feature_alias_id))) + JOIN variants ON ((variants.feature_id = outer_features.id))) + JOIN molecular_profiles_variants ON ((molecular_profiles_variants.variant_id = variants.id))) + JOIN molecular_profiles ON ((molecular_profiles.id = molecular_profiles_variants.molecular_profile_id))) + JOIN evidence_items ON ((evidence_items.molecular_profile_id = molecular_profiles.id))) + LEFT JOIN diseases ON ((diseases.id = evidence_items.disease_id))) + LEFT JOIN evidence_items_therapies ON ((evidence_items_therapies.evidence_item_id = evidence_items.id))) + LEFT JOIN therapies ON ((therapies.id = evidence_items_therapies.therapy_id))) + LEFT JOIN assertions ON ((assertions.molecular_profile_id = molecular_profiles.id))) + LEFT JOIN LATERAL ( SELECT therapies_1.id AS therapy_id, + count(DISTINCT evidence_items_1.id) AS total + FROM (((((evidence_items evidence_items_1 + JOIN molecular_profiles molecular_profiles_1 ON ((molecular_profiles_1.id = evidence_items_1.molecular_profile_id))) + JOIN molecular_profiles_variants molecular_profiles_variants_1 ON ((molecular_profiles_variants_1.molecular_profile_id = molecular_profiles_1.id))) + JOIN variants variants_1 ON ((variants_1.id = molecular_profiles_variants_1.variant_id))) + JOIN evidence_items_therapies evidence_items_therapies_1 ON ((evidence_items_therapies_1.evidence_item_id = evidence_items_1.id))) + JOIN therapies therapies_1 ON ((therapies_1.id = evidence_items_therapies_1.therapy_id))) + WHERE (variants_1.feature_id = outer_features.id) + GROUP BY therapies_1.id) therapy_count ON ((therapies.id = therapy_count.therapy_id))) + LEFT JOIN LATERAL ( SELECT diseases_1.id AS disease_id, + count(DISTINCT evidence_items_1.id) AS total + FROM ((((evidence_items evidence_items_1 + JOIN molecular_profiles molecular_profiles_1 ON ((molecular_profiles_1.id = evidence_items_1.molecular_profile_id))) + JOIN molecular_profiles_variants molecular_profiles_variants_1 ON ((molecular_profiles_variants_1.molecular_profile_id = molecular_profiles_1.id))) + JOIN variants variants_1 ON ((variants_1.id = molecular_profiles_variants_1.variant_id))) + JOIN diseases diseases_1 ON ((diseases_1.id = evidence_items_1.disease_id))) + WHERE (variants_1.feature_id = outer_features.id) + GROUP BY diseases_1.id) disease_count ON ((diseases.id = disease_count.disease_id))) + WHERE (((evidence_items.status)::text <> 'rejected'::text) AND (molecular_profiles.deprecated = false) AND (variants.deprecated = false)) + GROUP BY outer_features.id, outer_features.name; + SQL + add_index "feature_browse_table_rows", ["id"], name: "index_feature_browse_table_rows_on_id", unique: true + create_view "disease_browse_table_rows", materialized: true, sql_definition: <<-SQL SELECT diseases.id, diseases.name, diseases.display_name, diseases.doid, - array_agg(DISTINCT genes.name) AS gene_names, + json_agg(DISTINCT jsonb_build_object('name', features.name, 'id', features.id)) FILTER (WHERE (features.name IS NOT NULL)) AS features, count(DISTINCT evidence_items.id) AS evidence_item_count, count(DISTINCT variants.id) AS variant_count, count(DISTINCT assertions.id) AS assertion_count, - count(DISTINCT genes.id) AS gene_count + count(DISTINCT features.id) AS feature_count FROM (((((((diseases JOIN evidence_items ON ((diseases.id = evidence_items.disease_id))) LEFT JOIN assertions_evidence_items ON ((assertions_evidence_items.evidence_item_id = evidence_items.id))) @@ -1131,17 +1215,58 @@ JOIN molecular_profiles ON ((molecular_profiles.id = evidence_items.molecular_profile_id))) JOIN molecular_profiles_variants ON ((molecular_profiles_variants.molecular_profile_id = molecular_profiles.id))) JOIN variants ON ((variants.id = molecular_profiles_variants.variant_id))) - JOIN genes ON ((genes.id = variants.gene_id))) + JOIN features ON ((features.id = variants.feature_id))) WHERE (((evidence_items.status)::text <> 'rejected'::text) AND (diseases.deprecated = false)) GROUP BY diseases.id, diseases.name, diseases.doid; SQL add_index "disease_browse_table_rows", ["id"], name: "index_disease_browse_table_rows_on_id", unique: true + create_view "molecular_profile_browse_table_rows", materialized: true, sql_definition: <<-SQL + SELECT outer_mps.id, + outer_mps.name, + count(DISTINCT evidence_items.id) AS evidence_item_count, + array_agg(DISTINCT molecular_profile_aliases.name ORDER BY molecular_profile_aliases.name) AS alias_names, + json_agg(DISTINCT jsonb_build_object('name', features.name, 'id', features.id)) FILTER (WHERE (features.name IS NOT NULL)) AS features, + json_agg(DISTINCT jsonb_build_object('name', variants.name, 'id', variants.id)) FILTER (WHERE (variants.name IS NOT NULL)) AS variants, + json_agg(DISTINCT jsonb_build_object('name', diseases.name, 'id', diseases.id, 'total', disease_count.total)) FILTER (WHERE (diseases.name IS NOT NULL)) AS diseases, + json_agg(DISTINCT jsonb_build_object('name', therapies.name, 'id', therapies.id, 'total', therapy_count.total)) FILTER (WHERE (therapies.name IS NOT NULL)) AS therapies, + count(DISTINCT assertions.id) AS assertion_count, + count(DISTINCT variants.id) AS variant_count, + outer_mps.evidence_score + FROM ((((((((((((molecular_profiles outer_mps + LEFT JOIN evidence_items ON ((evidence_items.molecular_profile_id = outer_mps.id))) + JOIN molecular_profiles_variants ON ((outer_mps.id = molecular_profiles_variants.molecular_profile_id))) + JOIN variants ON ((molecular_profiles_variants.variant_id = variants.id))) + JOIN features ON ((features.id = variants.feature_id))) + LEFT JOIN diseases ON ((diseases.id = evidence_items.disease_id))) + LEFT JOIN evidence_items_therapies ON ((evidence_items_therapies.evidence_item_id = evidence_items.id))) + LEFT JOIN therapies ON ((therapies.id = evidence_items_therapies.therapy_id))) + LEFT JOIN assertions ON ((assertions.molecular_profile_id = outer_mps.id))) + LEFT JOIN molecular_profile_aliases_molecular_profiles ON ((molecular_profile_aliases_molecular_profiles.molecular_profile_id = outer_mps.id))) + LEFT JOIN molecular_profile_aliases ON ((molecular_profile_aliases.id = molecular_profile_aliases_molecular_profiles.molecular_profile_alias_id))) + LEFT JOIN LATERAL ( SELECT therapies_1.id AS therapy_id, + count(DISTINCT evidence_items_1.id) AS total + FROM ((evidence_items evidence_items_1 + JOIN evidence_items_therapies evidence_items_therapies_1 ON ((evidence_items_therapies_1.evidence_item_id = evidence_items_1.id))) + JOIN therapies therapies_1 ON ((therapies_1.id = evidence_items_therapies_1.therapy_id))) + WHERE (evidence_items_1.molecular_profile_id = outer_mps.id) + GROUP BY therapies_1.id) therapy_count ON ((therapies.id = therapy_count.therapy_id))) + LEFT JOIN LATERAL ( SELECT diseases_1.id AS disease_id, + count(DISTINCT evidence_items_1.id) AS total + FROM (evidence_items evidence_items_1 + JOIN diseases diseases_1 ON ((diseases_1.id = evidence_items_1.disease_id))) + WHERE (evidence_items_1.molecular_profile_id = outer_mps.id) + GROUP BY diseases_1.id) disease_count ON ((diseases.id = disease_count.disease_id))) + WHERE (outer_mps.deprecated = false) + GROUP BY outer_mps.id, outer_mps.name, outer_mps.evidence_score; + SQL + add_index "molecular_profile_browse_table_rows", ["id"], name: "index_molecular_profile_browse_table_rows_on_id", unique: true + create_view "variant_browse_table_rows", materialized: true, sql_definition: <<-SQL SELECT outer_variants.id, outer_variants.name, - genes.id AS gene_id, - genes.name AS gene_name, + features.id AS feature_id, + features.name AS feature_name, array_agg(DISTINCT variant_aliases.name ORDER BY variant_aliases.name) AS alias_names, array_agg(DISTINCT variant_types.id) AS variant_type_ids, json_agg(DISTINCT jsonb_build_object('name', variant_types.display_name, 'id', variant_types.id)) FILTER (WHERE (variant_types.* IS NOT NULL)) AS variant_types, @@ -1156,7 +1281,7 @@ JOIN molecular_profiles_variants ON ((molecular_profiles_variants.variant_id = outer_variants.id))) JOIN molecular_profiles ON ((molecular_profiles.id = molecular_profiles_variants.molecular_profile_id))) LEFT JOIN evidence_items ON ((evidence_items.molecular_profile_id = molecular_profiles.id))) - JOIN genes ON ((genes.id = outer_variants.gene_id))) + JOIN features ON ((features.id = outer_variants.feature_id))) LEFT JOIN diseases ON ((diseases.id = evidence_items.disease_id))) LEFT JOIN evidence_items_therapies ON ((evidence_items_therapies.evidence_item_id = evidence_items.id))) LEFT JOIN therapies ON ((therapies.id = evidence_items_therapies.therapy_id))) @@ -1181,44 +1306,8 @@ WHERE (molecular_profiles_variants_1.variant_id = outer_variants.id) GROUP BY diseases_1.id) disease_count ON ((diseases.id = disease_count.disease_id))) WHERE ((((evidence_items.status)::text <> 'rejected'::text) OR (evidence_items.status IS NULL)) AND (outer_variants.deprecated = false)) - GROUP BY outer_variants.id, outer_variants.name, genes.id, genes.name; + GROUP BY outer_variants.id, outer_variants.name, features.id, features.name; SQL add_index "variant_browse_table_rows", ["id"], name: "index_variant_browse_table_rows_on_id", unique: true - create_view "evidence_items_by_types", sql_definition: <<-SQL - SELECT mp.id AS molecular_profile_id, - sum( - CASE - WHEN (ei.evidence_type = 0) THEN 1 - ELSE 0 - END) AS diagnostic_count, - sum( - CASE - WHEN (ei.evidence_type = 1) THEN 1 - ELSE 0 - END) AS prognostic_count, - sum( - CASE - WHEN (ei.evidence_type = 2) THEN 1 - ELSE 0 - END) AS predictive_count, - sum( - CASE - WHEN (ei.evidence_type = 3) THEN 1 - ELSE 0 - END) AS predisposing_count, - sum( - CASE - WHEN (ei.evidence_type = 4) THEN 1 - ELSE 0 - END) AS functional_count, - sum( - CASE - WHEN (ei.evidence_type = 5) THEN 1 - ELSE 0 - END) AS oncogenic_count - FROM (molecular_profiles mp - JOIN evidence_items ei ON (((mp.id = ei.molecular_profile_id) AND (ei.deleted = false) AND ((ei.status)::text <> 'rejected'::text)))) - GROUP BY mp.id; - SQL end From c6a7d0768ec354c96e4c8a77c15475ad7cdae8a2 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 10 Jan 2024 10:58:58 -0600 Subject: [PATCH 7/8] increase max page size to 100 --- server/app/graphql/civic2_schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/graphql/civic2_schema.rb b/server/app/graphql/civic2_schema.rb index ee70bdc20..5a44f45fc 100644 --- a/server/app/graphql/civic2_schema.rb +++ b/server/app/graphql/civic2_schema.rb @@ -1,5 +1,5 @@ class Civic2Schema < GraphQL::Schema - default_max_page_size 50 + default_max_page_size 100 mutation(Types::MutationType) query(Types::QueryType) From 3443f8de4ec13fe15dfbc9634938eb372a1f0544 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Wed, 10 Jan 2024 11:25:13 -0600 Subject: [PATCH 8/8] update depreacted checkout action --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5ef74b30a..0cfb64f25 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,7 +32,7 @@ jobs: - name: Adding Known Hosts run: ssh-keyscan -H ${{ secrets.SSH_HOST }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: