-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Add support for native GitHub media attachments #208
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0aaa9bf
Implement proper github attachments handling
savokr-asana 96a394b
Add support for all possible attachment types
savokr-asana 38436c2
Cleanup after old version
savokr-asana 8f15853
Merge branch 'master' into saveliinovikov-add-media-attachments
savokr-asana 9c8a46b
Fix formatter + mypy + tests
savokr-asana 6d7f286
Remove unnecessary env vars changes
savokr-asana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,40 @@ | ||
| import boto3 # type: ignore | ||
| from datetime import timedelta | ||
| from src.config import AWS_REGION, LOCK_TABLE | ||
| from src.config import LOCK_TABLE, AWS_REGION | ||
| from python_dynamodb_lock.python_dynamodb_lock import DynamoDBLockClient # type: ignore | ||
|
|
||
| # Lazy initialization - these will be created when first accessed | ||
| _dynamodb_resource = None | ||
| _dynamodb_lock_client = None | ||
|
|
||
| dynamodb_resource = boto3.resource("dynamodb", region_name=AWS_REGION) | ||
|
|
||
| dynamodb_lock_client = DynamoDBLockClient( | ||
| dynamodb_resource, | ||
| table_name=LOCK_TABLE, | ||
| lease_duration=timedelta(seconds=20), | ||
| expiry_period=timedelta( | ||
| minutes=2 | ||
| ), # The Lambda function has a 120 second timeout by default | ||
| ) | ||
| def get_dynamodb_resource(): | ||
| """Get the DynamoDB resource, creating it lazily on first access.""" | ||
| global _dynamodb_resource | ||
| if _dynamodb_resource is None: | ||
| _dynamodb_resource = boto3.resource("dynamodb", region_name=AWS_REGION) | ||
| return _dynamodb_resource | ||
|
|
||
|
|
||
| def get_dynamodb_lock_client(): | ||
| """Get the DynamoDB lock client, creating it lazily on first access.""" | ||
| global _dynamodb_lock_client | ||
| if _dynamodb_lock_client is None: | ||
| _dynamodb_lock_client = DynamoDBLockClient( | ||
| get_dynamodb_resource(), | ||
| table_name=LOCK_TABLE, | ||
| lease_duration=timedelta(seconds=20), | ||
| expiry_period=timedelta( | ||
| minutes=2 | ||
| ), # The Lambda function has a 120 second timeout by default | ||
| ) | ||
| return _dynamodb_lock_client | ||
|
|
||
|
|
||
| # Create a lazy-loading module-level variable | ||
| class _LazyLockClient: | ||
| def __getattr__(self, name): | ||
| return getattr(get_dynamodb_lock_client(), name) | ||
|
|
||
|
|
||
| dynamodb_lock_client = _LazyLockClient() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| } | ||
| } | ||
| body | ||
| bodyHTML | ||
| ... on IssueComment { | ||
| url | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ | |
| } | ||
| publishedAt | ||
| body | ||
| bodyHTML | ||
| url | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was suggested by cursor, and I decided to leave it. From my understanding it is a best-practice to initialize things like that lazily, so it's a small improvement to current implementation.
Let me know if you think it's better to remove it.
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.
Makes sense and looks good to keep - though I don't think it'll be huge improvement since we always need to lock client to be fully set up whenever we access it.