-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/tooltip dashboard #45
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
10 commits
Select commit
Hold shift + click to select a range
e1a86ba
fix order of elements.
maxi07 2cd3940
fix live updates
maxi07 b601d8b
fix update color
maxi07 d16aa2d
fix live badges
maxi07 6e86dde
fix matching badges
maxi07 7ba53db
fix flake8
maxi07 c8a2bd9
fix badge color
maxi07 0282a2a
add tests
maxi07 58e4aae
add number validation
maxi07 8975efb
add tests
maxi07 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
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 |
|---|---|---|
|
|
@@ -224,7 +224,7 @@ def upload_small(item: ProcessItem, onedriveitem: OneDriveDestination) -> bool: | |
| file_size = os.path.getsize(item.ocr_file) | ||
| if file_size > 250 * 1024 * 1024: | ||
| logger.error(f"File {item.ocr_file} is larger than 250MB, using chunked upload") | ||
| return upload(item) | ||
| return upload(item, onedriveitem) | ||
| file_size_kb = file_size / 1024 | ||
| file_size_mb = file_size_kb / 1024 | ||
| logger.debug(f"File size: {file_size} bytes ({file_size_kb:.2f} KB, {file_size_mb:.2f} MB)") | ||
|
|
@@ -245,9 +245,10 @@ def upload_small(item: ProcessItem, onedriveitem: OneDriveDestination) -> bool: | |
| webUrl = response.json().get("webUrl") | ||
| if webUrl: | ||
| logger.debug(f"File is accessible at {webUrl}") | ||
| item.web_url.append(webUrl) | ||
| # Store the web URL in the OneDriveDestination object for later processing | ||
| onedriveitem.web_url = webUrl | ||
| # Only update the file name, web_url will be handled in batch by upload_service | ||
| update_scanneddata_database(item, { | ||
| "web_url": ",".join(item.web_url), | ||
| "file_name": response.json().get("name", item.filename) | ||
| } | ||
| ) | ||
|
|
@@ -263,16 +264,16 @@ def upload_small(item: ProcessItem, onedriveitem: OneDriveDestination) -> bool: | |
|
|
||
|
|
||
| @retry(stop=stop_after_attempt(3), wait=wait_random_exponential(multiplier=10, min=10, max=60)) | ||
| def upload(item: ProcessItem) -> bool: | ||
| def upload(item: ProcessItem, onedriveitem: OneDriveDestination) -> bool: | ||
| try: | ||
| logger.info(f"Uploading file {item.ocr_file} to OneDrive") | ||
| logger.info(f"Uploading file {item.ocr_file} to OneDrive: {onedriveitem.remote_file_path}") | ||
| access_token = get_access_token() | ||
| if not access_token: | ||
| logger.error("No access token available to upload file") | ||
| return False | ||
|
|
||
| file_size = os.path.getsize(item.ocr_file) | ||
| upload_session_url = f"https://graph.microsoft.com/v1.0/drives/{item.remote_drive_id}/items/{item.remote_folder_id}:/{item.filename}:/createUploadSession" | ||
| upload_session_url = f"https://graph.microsoft.com/v1.0/drives/{onedriveitem.remote_drive_id}/items/{onedriveitem.remote_folder_id}:/{item.filename}:/createUploadSession" | ||
|
|
||
| # Create an upload session | ||
| logger.debug(f"Creating upload session for {item.ocr_file} to {upload_session_url}") | ||
|
|
@@ -322,9 +323,15 @@ def upload(item: ProcessItem) -> bool: | |
| webUrl = chunk_response.json().get("webUrl") | ||
| if webUrl: | ||
| logger.debug(f"File is accessible at {webUrl}") | ||
| update_scanneddata_database(item, {"web_url": webUrl, "remote_filepath": item.remote_file_path}) | ||
|
|
||
| logger.info(f"File {item.ocr_file} uploaded successfully to {item.remote_file_path}") | ||
| # Store the web URL in the OneDriveDestination object for later processing | ||
| onedriveitem.web_url = webUrl | ||
| # Only update the file name, web_url will be handled in batch by upload_service | ||
| update_scanneddata_database(item, { | ||
| "file_name": chunk_response.json().get("name", item.filename) | ||
| }) | ||
|
|
||
| logger.info(f"File {item.ocr_file} uploaded successfully to {onedriveitem.remote_file_path}") | ||
| return True | ||
|
Comment on lines
+332
to
+334
|
||
| except requests.exceptions.RequestException as e: | ||
| logger.error(f"Request exception occurred during upload: {str(e)}") | ||
| except Exception as e: | ||
|
|
||
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.
The return statement is inside the try block but outside the main logic flow, which means it will always return True even if the upload fails. This should be moved to the end of the successful upload logic.