Skip to content

Conversation

jasonyuezhang
Copy link
Owner

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

)
return [serialize_sentry_app(app) for app in published_apps]

def get_sentry_apps_for_organization(self, *, organization_id: int) -> list[RpcSentryApp]:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/propel explain this function

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/propel explain this function

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/propel explain this function

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_sentry_apps_for_organization function, added at line 337 in src/sentry/sentry_apps/services/app/impl.py, is responsible for retrieving all active Sentry Apps for a given organization.

Here's a breakdown of its functionality:

  • Purpose: To fetch a list of Sentry Apps that are owned by a specific organization and are currently active (not in the process of being deleted).
  • Parameters: It takes one keyword argument:
    • organization_id (int): The unique identifier of the organization whose Sentry Apps are to be retrieved.
  • Logic:
    1. It queries the SentryApp database table.
    2. It filters these apps based on two conditions:
      • The owner_id of the Sentry App must match the provided organization_id.
      • The Sentry App must have an associated application (i.e., application__isnull=False).
    3. It then excludes any Sentry Apps that have a status of DELETION_IN_PROGRESS, ensuring only truly active apps are returned.
    4. Finally, it serializes the resulting SentryApp objects into RpcSentryApp format and returns them as a list.
  • Return Value: A list of RpcSentryApp objects, representing the active Sentry Apps for the specified organization.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/propel explain this function

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/propel what this function does?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_sentry_apps_for_organization function, located at line 337 in src/sentry/sentry_apps/services/app/impl.py, is designed to retrieve all active Sentry Apps associated with a specific organization.

Functionality Breakdown:

  • Purpose: To fetch a list of Sentry Apps that are owned by the given organization_id and are currently in an active state (i.e., not marked for deletion).
  • Parameters: It accepts one keyword argument:
    • organization_id (int): The unique identifier of the organization for which to retrieve Sentry Apps.
  • Logic:
    1. It queries the SentryApp database model.
    2. It filters these applications to include only those where the owner_id matches the provided organization_id and where an application object is associated (meaning application__isnull=False).
    3. It explicitly excludes any Sentry Apps that have a status of SentryAppStatus.DELETION_IN_PROGRESS.
    4. Finally, it serializes the filtered SentryApp objects into RpcSentryApp format and returns them as a list.
  • Return Value: A list of RpcSentryApp objects, each representing an active Sentry App belonging to the specified organization.

To improve clarity and completeness, I suggest expanding the docstring for this function to include details about its arguments and return value.

Suggested change
def get_sentry_apps_for_organization(self, *, organization_id: int) -> list[RpcSentryApp]:
"""
Get active Sentry Apps for a given organization.
Args:
organization_id (int): The ID of the organization.
Returns:
list[RpcSentryApp]: A list of serialized active Sentry Apps for the organization.
"""

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

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

Successfully merging this pull request may close these issues.

1 participant