-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add URL column to CSV export for items #141
Add URL column to CSV export for items #141
Conversation
WalkthroughWalkthroughThe recent changes enhance the functionality of the V1Controller and related services by introducing a URL feature for exports. This improvement enables the inclusion of URLs in the CSV export of items, thereby facilitating better reporting and usage in applications like barcode generation. Overall, the enhancements improve flexibility and data representation in the API. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Controller
participant Service
participant Reporting
User->>API: Requests CSV export
API->>Controller: HandleItemsExport
Controller->>Controller: stripPathFromURL
Controller->>Service: ExportCSV with hbURL
Service->>Reporting: ReadItems with hbURL
Reporting->>Reporting: Generate URLs for items
Reporting->>Service: Return CSV rows
Service->>Controller: Return CSV data
Controller->>API: Return CSV export to User
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Caution
Inline review comments failed to post
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- backend/app/api/handlers/v1/v1_ctrl_items.go (3 hunks)
- backend/internal/core/services/reporting/io_row.go (1 hunks)
- backend/internal/core/services/reporting/io_sheet.go (4 hunks)
- backend/internal/core/services/service_items.go (1 hunks)
Additional comments not posted (8)
backend/internal/core/services/reporting/io_row.go (1)
21-21
: Field addition approved.The
URL
field has been correctly added to theExportCSVRow
struct with the appropriate CSV tag.backend/internal/core/services/reporting/io_sheet.go (4)
156-156
: Parameter addition approved.The
hbURL
parameter has been correctly added to theReadItems
method, expanding its functionality.
181-182
: URL generation logic approved.The
generateItemURL
function is correctly used to generate item URLs based on thehbURL
parameter.
206-206
: Field assignment approved.The
URL
field is correctly assigned the generated URL value in theExportCSVRow
struct.
258-264
: Function addition approved.The
generateItemURL
function correctly encapsulates the URL generation logic, improving code organization and readability.backend/internal/core/services/service_items.go (2)
332-332
: Parameter addition approved.The
hbURL
parameter has been correctly added to theExportCSV
method, expanding its functionality.
340-340
: Internal call update approved.The internal call to
sheet.ReadItems
has been correctly updated to include the newhbURL
parameter.backend/app/api/handlers/v1/v1_ctrl_items.go (1)
Line range hint
337-343
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
ExportCSV
match the new signature and that thestripPathFromURL
function works as intended.Verification successful
Verification Successful: Function Usage and Implementation Confirmed
The
stripPathFromURL
function correctly processes the URL by stripping the path and returning only the scheme and host. All function calls toExportCSV
match the new signature, and the implementation ofstripPathFromURL
is verified to work as intended.
stripPathFromURL
implementation:func stripPathFromURL(rawURL string) string { parsedURL, err := url.Parse(rawURL) if err != nil { return "" } strippedURL := url.URL{Scheme: parsedURL.Scheme, Host: parsedURL.Host} return strippedURL.String() }Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `ExportCSV` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go -A 5 $'ExportCSV'Length of output: 7220
Script:
#!/bin/bash # Description: Locate the definition of the `stripPathFromURL` function and verify its implementation. # Test: Search for the function definition. Expect: Locate the function and review its implementation. rg --type go 'func stripPathFromURL'Length of output: 129
Script:
#!/bin/bash # Description: Extract the implementation of the `stripPathFromURL` function for review. # Test: Locate and display the function implementation. Expect: Review the function code. rg --type go -A 10 'func stripPathFromURL' backend/app/api/handlers/v1/v1_ctrl_items.goLength of output: 309
Comments failed to post (1)
backend/app/api/handlers/v1/v1_ctrl_items.go
352-363: Consider enhancing error handling.
The function correctly strips the path from the URL, but it might be beneficial to log the error when URL parsing fails for better debugging.
func stripPathFromURL(rawURL string) string { parsedURL, err := url.Parse(rawURL) if err != nil { + log.Err(err).Msg("failed to parse URL") return "" } strippedURL := url.URL{Scheme: parsedURL.Scheme, Host: parsedURL.Host} return strippedURL.String() }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.func stripPathFromURL(rawURL string) string { parsedURL, err := url.Parse(rawURL) if (err != nil) { log.Err(err).Msg("failed to parse URL") return "" } strippedURL := url.URL{Scheme: parsedURL.Scheme, Host: parsedURL.Host} return strippedURL.String() }
1b0d562
to
fb01b6a
Compare
Enhanced the CSV export functionality to include a URL field for each item. This change required updating the export logic to generate and include item URLs based on the request's referer header.
fb01b6a
to
e68a1e2
Compare
@coderabbitai full review |
Actions performedFull review triggered. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- backend/app/api/handlers/v1/controller.go (2 hunks)
- backend/app/api/handlers/v1/v1_ctrl_items.go (3 hunks)
- backend/app/api/routes.go (2 hunks)
- backend/internal/core/services/reporting/io_row.go (1 hunks)
- backend/internal/core/services/reporting/io_sheet.go (4 hunks)
- backend/internal/core/services/service_items.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- backend/app/api/handlers/v1/v1_ctrl_items.go
- backend/internal/core/services/reporting/io_row.go
- backend/internal/core/services/reporting/io_sheet.go
- backend/internal/core/services/service_items.go
Additional comments not posted (3)
backend/app/api/handlers/v1/controller.go (2)
60-64
: FunctionWithURL
added successfully.The addition of the
WithURL
function aligns with the existing pattern for setting controller options. This enhances configurability.
74-74
: Fieldurl
added toV1Controller
struct.The addition of the
url
field to theV1Controller
struct is appropriate and integrates well with the newWithURL
function.backend/app/api/routes.go (1)
58-58
: EnhancedmountRoutes
with dynamic URL setting.The inclusion of
v1.WithURL(fmt.Sprintf("%s:%s", a.conf.Web.Host, a.conf.Web.Port))
dynamically sets the base URL for the API, improving flexibility and configurability.
@coderabbitai review |
Actions performedReview triggered.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... Files selected for processing (6)
Tip Migrating from UI to YAML configuration.Use the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- backend/app/api/handlers/v1/controller.go (2 hunks)
- backend/app/api/handlers/v1/v1_ctrl_items.go (3 hunks)
- backend/app/api/routes.go (2 hunks)
- backend/internal/core/services/reporting/io_row.go (1 hunks)
- backend/internal/core/services/reporting/io_sheet.go (4 hunks)
- backend/internal/core/services/service_items.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- backend/app/api/handlers/v1/controller.go
- backend/app/api/routes.go
- backend/internal/core/services/reporting/io_row.go
- backend/internal/core/services/reporting/io_sheet.go
Additional comments not posted (6)
backend/internal/core/services/service_items.go (2)
332-332
: Parameter added:hbURL
.The
ExportCSV
function now includes thehbURL
parameter to enhance the export process.
340-340
: Verify the usage ofhbURL
insheet.ReadItems
.Ensure that the
hbURL
parameter is correctly utilized within thesheet.ReadItems
function.Verification successful
hbURL is correctly utilized within the
sheet.ReadItems
function.The parameter
hbURL
is used in theReadItems
function in theio_sheet.go
file, specifically in the line:url := generateItemURL(item, hbURL)This confirms that
hbURL
is being passed and utilized appropriately within the function.
- File:
backend/internal/core/services/reporting/io_sheet.go
- Function:
func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, GID uuid.UUID, repos *repo.AllRepos, hbURL string) error
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `hbURL` parameter in the `sheet.ReadItems` function. # Test: Search for the function definition and usage. Expect: Correct utilization of the `hbURL` parameter. rg --type go -A 10 'func ReadItems' | rg 'hbURL'Length of output: 48
Script:
#!/bin/bash # Locate the definition of the ReadItems function and verify the usage of hbURL within it. ast-grep --lang go --pattern 'func ReadItems($_, $_, $_, $_, $_) { $$$ }'Length of output: 75
Script:
#!/bin/bash # Locate the definition of the ReadItems function and verify the usage of hbURL within it. rg 'func ReadItems' -A 50 --type go | rg -A 50 'ReadItems' | rg 'hbURL'Length of output: 69
Script:
#!/bin/bash # Locate the definition of the ReadItems function and inspect its parameters and body. rg 'func ReadItems' -A 50 --type goLength of output: 37
Script:
#!/bin/bash # Locate the definition of the ReadItems function and inspect its parameters and body. rg 'ReadItems' -A 50 --type goLength of output: 5217
backend/app/api/handlers/v1/v1_ctrl_items.go (4)
337-337
: Parameter added:hbURL
.The
HandleItemsExport
function now includes thehbURL
parameter derived from the "Referer" header.
361-373
: New utility function:stripPathFromURL
.The function
stripPathFromURL
removes the path component from a given URL, returning only the scheme and host.
361-373
: Verify the usage ofstripPathFromURL
.Ensure that the
stripPathFromURL
function is correctly utilized within the codebase.Verification successful
The usage of
stripPathFromURL
is verified and correct.The function is appropriately utilized within the
getHBURL
function, which is called in theHandleItemsExport
method of theV1Controller
struct. The implementation ensures that the path is stripped from the URL as intended.
stripPathFromURL
is used to process URLs correctly within the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `stripPathFromURL` function. # Test: Search for the function definition and usage. Expect: Correct utilization of the `stripPathFromURL` function. rg --type go -A 10 'stripPathFromURL'Length of output: 1159
Script:
#!/bin/bash # Description: Gather more context around the usage of the `stripPathFromURL` function. # Search for the function that calls `stripPathFromURL` and include surrounding lines for context. rg --type go -A 20 -B 20 'stripPathFromURL'Length of output: 2550
Script:
#!/bin/bash # Description: Gather more context around the usage of the `getHBURL` function. # Search for the usage of the `getHBURL` function within the codebase. rg --type go -A 10 -B 10 'getHBURL'Length of output: 2710
352-358
: Verify the behavior ofgetHBURL
.Ensure that the
getHBURL
function correctly processes the "Referer" header and fallback URL.Verification successful
Verifying the behavior of
getHBURL
.Let's gather more information by locating the implementation of
stripPathFromURL
and identifying all the usages ofgetHBURL
in the codebase.
Verifying the behavior of
getHBURL
.Let's re-run the search for all usages of
getHBURL
with the correct regex syntax to ensure it correctly processes the "Referer" header and fallback URL.
Verified the behavior of
getHBURL
.The
getHBURL
function correctly processes the "Referer" header and fallback URL by assigning the "Referer" header tohbURL
, using the fallback if the header is empty, and stripping the path from the URL. Its usage in theExportCSV
method confirms its intended functionality.
backend/app/api/handlers/v1/v1_ctrl_items.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the behavior of the `getHBURL` function. # Test: Search for the function definition and usage. Expect: Correct processing of the "Referer" header and fallback URL. rg --type go -A 10 'func getHBURL'Length of output: 798
Script:
#!/bin/bash # Description: Locate the implementation of `stripPathFromURL` and identify all usages of `getHBURL`. # Search for the implementation of `stripPathFromURL`. rg --type go -A 10 'func stripPathFromURL' # Search for all usages of `getHBURL`. rg --type go 'getHBURL('Length of output: 897
Script:
#!/bin/bash # Description: Identify all usages of `getHBURL` in the codebase. # Search for all usages of `getHBURL`. rg --type go 'getHBURL\('Length of output: 290
Fantastic! Thanks so much for the assistance @Rshep3087 🥇 |
… v0.13.0@90328a8 by renovate (#24463) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/sysadminsmedia/homebox](https://github.com/sysadminsmedia/homebox) | minor | `0.12.1` -> `0.13.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>sysadminsmedia/homebox (ghcr.io/sysadminsmedia/homebox)</summary> ### [`v0.13.0`](https://github.com/sysadminsmedia/homebox/releases/tag/v0.13.0) [Compare Source](https://github.com/sysadminsmedia/homebox/compare/v0.12.1...v0.13.0) #### What's Changed - docs: update get-started.md by [@​eltociear](https://github.com/eltociear) in [https://github.com/sysadminsmedia/homebox/pull/106](https://github.com/sysadminsmedia/homebox/pull/106) - Update location pricing to include quantity in calculation by [@​katosdev](https://github.com/katosdev) in [https://github.com/sysadminsmedia/homebox/pull/123](https://github.com/sysadminsmedia/homebox/pull/123) - Create a Github Workflow to keep currencies in sync from API by [@​katosdev](https://github.com/katosdev) in [https://github.com/sysadminsmedia/homebox/pull/129](https://github.com/sysadminsmedia/homebox/pull/129) - Update update_currencies.py to fix error handling by [@​katosdev](https://github.com/katosdev) in [https://github.com/sysadminsmedia/homebox/pull/130](https://github.com/sysadminsmedia/homebox/pull/130) - Skip commit attempt if currencies already synced with API by [@​katosdev](https://github.com/katosdev) in [https://github.com/sysadminsmedia/homebox/pull/131](https://github.com/sysadminsmedia/homebox/pull/131) - Force rebase on Update-currencies action by [@​katosdev](https://github.com/katosdev) in [https://github.com/sysadminsmedia/homebox/pull/132](https://github.com/sysadminsmedia/homebox/pull/132) - Update currencies by [@​github-actions](https://github.com/github-actions) in [https://github.com/sysadminsmedia/homebox/pull/133](https://github.com/sysadminsmedia/homebox/pull/133) - Add nmprc to automatically hoist dependencies by [@​PatrickDaG](https://github.com/PatrickDaG) in [https://github.com/sysadminsmedia/homebox/pull/136](https://github.com/sysadminsmedia/homebox/pull/136) - Add URL column to CSV export for items by [@​Rshep3087](https://github.com/Rshep3087) in [https://github.com/sysadminsmedia/homebox/pull/141](https://github.com/sysadminsmedia/homebox/pull/141) - Enable Sorting on Search By Created and Updated At by [@​Rshep3087](https://github.com/Rshep3087) in [https://github.com/sysadminsmedia/homebox/pull/140](https://github.com/sysadminsmedia/homebox/pull/140) - Update currencies by [@​github-actions](https://github.com/github-actions) in [https://github.com/sysadminsmedia/homebox/pull/143](https://github.com/sysadminsmedia/homebox/pull/143) - Splitting dependencies into separate docker layers (better caching) by [@​tankerkiller125](https://github.com/tankerkiller125) in [https://github.com/sysadminsmedia/homebox/pull/142](https://github.com/sysadminsmedia/homebox/pull/142) - chore: update openapi documentation by [@​tankerkiller125](https://github.com/tankerkiller125) in [https://github.com/sysadminsmedia/homebox/pull/148](https://github.com/sysadminsmedia/homebox/pull/148) #### New Contributors - [@​eltociear](https://github.com/eltociear) made their first contribution in [https://github.com/sysadminsmedia/homebox/pull/106](https://github.com/sysadminsmedia/homebox/pull/106) - [@​github-actions](https://github.com/github-actions) made their first contribution in [https://github.com/sysadminsmedia/homebox/pull/133](https://github.com/sysadminsmedia/homebox/pull/133) - [@​PatrickDaG](https://github.com/PatrickDaG) made their first contribution in [https://github.com/sysadminsmedia/homebox/pull/136](https://github.com/sysadminsmedia/homebox/pull/136) - [@​Rshep3087](https://github.com/Rshep3087) made their first contribution in [https://github.com/sysadminsmedia/homebox/pull/141](https://github.com/sysadminsmedia/homebox/pull/141) **Full Changelog**: sysadminsmedia/homebox@v0.12.1...v0.13.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44LjMiLCJ1cGRhdGVkSW5WZXIiOiIzOC44LjMiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIiLCJsYWJlbHMiOlsiYXV0b21lcmdlIiwidXBkYXRlL2RvY2tlci9nZW5lcmFsL25vbi1tYWpvciJdfQ==-->
Enhanced the CSV export functionality to include a URL field for each item. This change required updating the export logic to generate and include item URLs based on the request's referrer header.
What type of PR is this?
What this PR does / why we need it:
This PR adds the export of a URL column.
Which issue(s) this PR fixes:
Fixes #126
Special notes for your reviewer:
I did not include the field in the import docs, because it will only be in the export.
I am open to using a different solution to getting the host/port for the service. We have it in the config, but didn't want to expand the API of the routes.
Summary by CodeRabbit
New Features
Enhancements
Bug Fixes