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

Update BQ Documentation: new tables added #203

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

belmai
Copy link

@belmai belmai commented Oct 22, 2024

User description

This PR introduces documentation for three new tables that extract specific objects from the activities table, allowing for easier and more detailed analytics:

  1. Actions Table:
    Added description of the actions table, which captures data about orchestrated actions within care flows. It includes information on action definition, last state, associated objects, and relationships with care flows, steps, and tracks.

  2. Steps Table:
    Included documentation for the steps table, which contains data about orchestrated steps within care flows. This table provides information on step definition, timing, last status, and associations with care flows and tracks.

  3. Tracks Table:
    Added details about the tracks table, which captures data on orchestrated tracks within care flows. It includes information on track definition, timing, last status, and care flow associations.


PR Type

Documentation, Enhancement


Description

  • Introduced new components for rendering BigQuery tables: ActionsTableSpecs, StepsTableSpecs, and TracksTableSpecs.
  • Added new BigQuery table configurations for actions, steps, and tracks, enhancing data analytics capabilities.
  • Updated the activities table configuration with additional properties and improved descriptions.
  • Extended API types with new activity and decision-related types, including new mutations and queries.
  • Updated documentation to include new tables and their specifications, providing detailed insights into the data schema.

Changes walkthrough 📝

Relevant files
Enhancement
ActionsTableSpecs.tsx
Add ActionsTableSpecs component for actions table rendering

src/components/DataRepository/ActionsTableSpecs.tsx

  • Added a new component ActionsTableSpecs for rendering the actions
    table.
  • Utilizes actions configuration for table data.
  • Implements a table structure with columns for Column, Type, and
    Description.
  • +45/-0   
    StepsTableSpecs.tsx
    Add StepsTableSpecs component for steps table rendering   

    src/components/DataRepository/StepsTableSpecs.tsx

  • Added a new component StepsTableSpecs for rendering the steps table.
  • Utilizes steps configuration for table data.
  • Implements a table structure with columns for Column, Type, and
    Description.
  • +45/-0   
    TracksTableSpecs.tsx
    Add TracksTableSpecs component for tracks table rendering

    src/components/DataRepository/TracksTableSpecs.tsx

  • Added a new component TracksTableSpecs for rendering the tracks table.
  • Utilizes tracks configuration for table data.
  • Implements a table structure with columns for Column, Type, and
    Description.
  • +45/-0   
    index.ts
    Export new table specs components in index                             

    src/components/DataRepository/index.ts

  • Exported new components: ActionsTableSpecs, StepsTableSpecs, and
    TracksTableSpecs.
  • +3/-0     
    bq-tables.ts
    Add new BigQuery table configurations and update activities table

    src/config/bq-tables.ts

  • Added new BigQuery table configurations: actions, steps, and tracks.
  • Updated activities table with new properties and descriptions.
  • +269/-43
    mdx.tsx
    Update MDX configuration with new table specs components 

    src/config/mdx.tsx

  • Imported and added new components to MDX configuration:
    ActionsTableSpecs, StepsTableSpecs, TracksTableSpecs.
  • +6/-0     
    api.types.ts
    Extend API types with new activity and decision-related types

    src/types/generated/api.types.ts

  • Added new types and fields related to activities, decisions, and
    identity verification.
  • Introduced new mutations and queries for handling metadata and
    decision outputs.
  • +137/-82
    Documentation
    data-schema.mdx
    Document new BigQuery tables in data schema                           

    content/awell-orchestration/docs/data/bigquery/data-schema.mdx

  • Documented new tables: actions, steps, and tracks.
  • Added detailed descriptions and components for each new table.
  • +36/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    vercel bot commented Oct 22, 2024

    The latest updates on your projects. Learn more about Vercel for Git ↗︎

    Name Status Preview Comments Updated (UTC)
    developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 22, 2024 7:37pm

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Duplication
    The components for ActionsTableSpecs, StepsTableSpecs, and TracksTableSpecs have highly similar structures and code. Consider refactoring to a single component that accepts data as props to reduce duplication and improve maintainability.

    Data Model Changes
    Significant changes to the 'activities' table and additions of 'actions', 'steps', and 'tracks' tables suggest modifications in the data model. Ensure that these changes are well-documented and that any dependent systems or queries are updated accordingly.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Prevent data integrity issues by validating input fields

    Validate the activity_id and metadata fields in AddActivityMetadataInput to prevent
    invalid or malicious data submissions.

    src/types/generated/api.types.ts [192-194]

     export type AddActivityMetadataInput = {
    -  activity_id: Scalars['String']['input'];
    -  metadata: Scalars['JSON']['input'];
    +  activity_id: ValidatedStringInput;
    +  metadata: ValidatedJsonInput;
       note?: InputMaybe<Scalars['String']['input']>;
     };
    Suggestion importance[1-10]: 9

    Why: Validating input fields is essential for preventing invalid or malicious data submissions, which can lead to data integrity issues. This suggestion addresses a potential bug and is highly relevant for ensuring robust input handling.

    9
    Add null-checking to the map function to handle potential undefined or empty arrays gracefully

    Consider adding a fallback or error handling for the .map() function in case the
    actions array is empty or undefined to prevent runtime errors.

    src/components/DataRepository/ActionsTableSpecs.tsx [24-39]

    -{actions.map(({ property, type, description }) => (
    +{actions?.map(({ property, type, description }) => (
       <tr
         key={property}
         className="text-slate-900 dark:text-slate-100"
       >
         <td className="font-semibold py-4 pl-4 pr-3 sm:pl-6 md:pl-0">
           {property}
         </td>
         <td className="py-4 px-3 text-base">
           {type}
         </td>
         <td className="py-4 px-3 text-base">
           {description}
         </td>
       </tr>
     ))}
    Suggestion importance[1-10]: 7

    Why: The suggestion to add null-checking to the map function is valid as it prevents runtime errors when the actions array is undefined. This improves the robustness of the component.

    7
    Security
    Enhance security by sanitizing unstructured JSON data

    Ensure that the metadata field in the Activity type is properly handled in the
    backend to avoid potential security risks with unstructured data.

    src/types/generated/api.types.ts [72]

    -metadata?: Maybe<Scalars['JSON']['output']>;
    +metadata?: Maybe<Scalars['SanitizedJSON']['output']>;
    Suggestion importance[1-10]: 8

    Why: Sanitizing JSON data is crucial for preventing security vulnerabilities such as injection attacks. This suggestion is relevant and important for maintaining data integrity and security.

    8
    Enhancement
    Improve type safety by replacing any with a more specific type

    Consider using a more specific type than any for the input and output properties of
    the JSON scalar to ensure type safety.

    src/types/generated/api.types.ts [16]

    -JSON: { input: any; output: any; }
    +JSON: { input: JsonType; output: JsonType; }
    Suggestion importance[1-10]: 7

    Why: Replacing any with a more specific type enhances type safety, reducing the risk of runtime errors and improving code maintainability. However, the suggestion lacks a concrete type definition, which limits its immediate applicability.

    7
    Best practice
    Use a more unique identifier as the key prop for list items to improve re-render performance and stability

    Implement a unique key prop for each child in the list using a more unique
    identifier than property if available, to ensure stability in re-renders and list
    updates.

    src/components/DataRepository/StepsTableSpecs.tsx [24-39]

    -{steps.map(({ property, type, description }) => (
    +{steps.map(({ id, property, type, description }) => (
       <tr
    -    key={property}
    +    key={id}  # Assuming `id` is a more unique identifier
         className="text-slate-900 dark:text-slate-100"
       >
         <td className="font-semibold py-4 pl-4 pr-3 sm:pl-6 md:pl-0">
           {property}
         </td>
         <td className="py-4 px-3 text-base">
           {type}
         </td>
         <td className="py-4 px-3 text-base">
           {description}
         </td>
       </tr>
     ))}
    Suggestion importance[1-10]: 6

    Why: Using a more unique identifier for the key prop is a best practice that can enhance performance and stability during re-renders, although the suggestion assumes the presence of an id field without verifying its existence.

    6
    Ensure robust error handling by managing new enum values

    Add error handling for the new Decision enum value in ActivityObjectType to manage
    any potential issues arising from its usage in existing functions.

    src/types/generated/api.types.ts [139]

    -Decision = 'DECISION',
    +Decision = 'DECISION', // Ensure all switch/case handling this enum include a case for 'DECISION'
    Suggestion importance[1-10]: 6

    Why: Adding error handling for new enum values is a good practice to prevent unexpected behavior. However, the suggestion is more of a reminder than a concrete implementation, which slightly reduces its impact.

    6
    Verify the usage of all exported components to prevent dead code and maintain application consistency

    Ensure that all exported components from 'DataRepository' are properly imported and
    utilized in other parts of the application to maintain consistency and avoid dead
    code.

    src/components/DataRepository/index.ts [12-13]

     export * from './ActionsTableSpecs'
     export * from './StepsTableSpecs'
     export * from './TracksTableSpecs'
    +// Ensure these are used in other modules
    Suggestion importance[1-10]: 4

    Why: While ensuring that exported components are used is important for maintaining code quality, the suggestion is not directly actionable in the code itself and serves more as a reminder for developers.

    4
    Possible issue
    Verify that all necessary fields are present in the tracks data to prevent errors during rendering

    Ensure that the tracks data structure includes all necessary fields (property, type,
    description) as expected by the mapping function to avoid runtime errors.

    src/components/DataRepository/TracksTableSpecs.tsx [24-39]

    -{tracks.map(({ property, type, description }) => (
    +{tracks?.map(({ property, type, description }) => (
       <tr
         key={property}
         className="text-slate-900 dark:text-slate-100"
       >
         <td className="font-semibold py-4 pl-4 pr-3 sm:pl-6 md:pl-0">
           {property}
         </td>
         <td className="py-4 px-3 text-base">
           {type}
         </td>
         <td className="py-4 px-3 text-base">
           {description}
         </td>
       </tr>
     ))}
    Suggestion importance[1-10]: 5

    Why: The suggestion to ensure all necessary fields are present in the tracks data is valid, but it is more of a reminder to check data integrity rather than a direct code improvement.

    5

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant