I could have gone either way between this or /year/{year}/month/{month}/day/{day} i settled on this because it seemed easier that it matches the format of YYYY-MM-DD displayed on the GCD's site. But i could do it the other way if preferred.
This endpoint will help my automation efforts to auto generate variant imports for next week's releases each week.
Tested locally:
image.png (view on web)
https://github.com/GrandComicsDatabase/gcd-django/pull/700
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Hello @adam-knights, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new API endpoint designed to fetch comic book issues by their on-sale date. This functionality is crucial for streamlining automation processes, such as generating variant imports for upcoming releases, by providing a direct way to query issues based on a specific date.
/issue/on_sale_date/<str:date>/ has been introduced to retrieve comic book issues based on their on-sale date. The date format expected is YYYY-MM-DD.on_sale_date field, returning only issues that match the provided date and are not marked as deleted.IssuesByOnSaleDate view.IssuesByOnSaleDate class, a ListAPIView that filters Issue objects by on_sale_date.The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@gemini-code-assist[bot] commented on this pull request.
The pull request successfully introduces a new API endpoint to retrieve issues based on their on-sale date, which is a useful addition for automation. The implementation correctly sets up the URL routing and a ListAPIView with the appropriate serializer. However, it's crucial to add robust validation for the date parameter to ensure data integrity and provide clear error feedback to API consumers.
> + date = self.kwargs['date'] + return Issue.objects.filter(on_sale_date=date, + deleted=False)
The date parameter from the URL is directly used in the Issue.objects.filter query without any validation. If an invalid date string (e.g., '2023-13-01' or 'not-a-date') is provided, it could lead to unexpected query results or potential errors. It's critical to validate the input date format to ensure data integrity and provide a clear error message to the API consumer. You will also need to add import datetime and from rest_framework.exceptions import ValidationError to the top of the file.
- date = self.kwargs['date']
- return Issue.objects.filter(on_sale_date=date,
- deleted=False)
+ date_param = self.kwargs['date']
+ try:
+ # Validate the date string format
+ datetime.datetime.strptime(date_param, '%Y-%m-%d')
+ except ValueError:
+ raise ValidationError("Invalid date format. Please use YYYY-MM-DD.")
+
+ return Issue.objects.filter(on_sale_date=date_param,
+ deleted=False)
In apps/api/urls.py:
> + path('issue/on_sale_date/<str:date>/',
+ views.IssuesByOnSaleDate.as_view()),
The <str:date> path converter is very generic. While the view's docstring specifies YYYY-MM-DD, the URL pattern itself doesn't enforce this. It's good practice to make URL patterns as specific as possible. Although the primary validation will occur in the view, a more restrictive path converter (e.g., using a regex) could provide earlier feedback for malformed URLs.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Let me know if you want me to do either or both of those suggestions, i'll wait and see if the url pattern is ok with you first.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I could have gone either way between this or
/year/{year}/month/{month}/day/{day}i settled on this because it seemed easier that it matches the format of YYYY-MM-DD displayed on the GCD's site. But i could do it the other way if preferred.This endpoint will help my automation efforts to auto generate variant imports for next week's releases each week.
Tested locally:
image.png (view on web)
Hi,
Saw this and was wondering if you've (GCD) given any thought about using drf + django-filters (or some comparable package) to handle parameters instead of using url-based parameters? I've found it to be much more flexible. For example, for my issue list endpoint I use the following filters(1), which if I were to try to replicate using url-based parameters would a significant amount of work to get comparable results.
Anyway, just thought I'd inquire, since your API is still
(relatively) new.
1)
https://github.com/Metron-Project/metron/blob/c98320dd0415a726ef69597d1984e220002ce5c4/comicsdb/filters/issue.py#L20
-- Brian Pepple <bpe...@metron.cloud> https://about.me/brian.pepple
I wonder if instead of daily we should provide weekly, as does the site ?
How to handle incomplete, e.g. just year and month, or just even year, in the API ?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I did not know we had that :)
Yeah, i could change it to /api/on_sale_weekly/{year}/week/{weekNumber}/ to match
I had to look at how we do it, but i see its the ISO 8601 week date system, so i could re-use the 4th Jan trick / code in do_on_sale_weekly?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
or /api/issue/on_sale_weekly/{year}/week/{weekNumber}/ ?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I saw the option, and since we use django-filter otherwise in the site, we should definetely investigate.
But, if we allow more generic searches on issues, we also need to investigate pagination or limits on the response size. How do you handle that ?
I believe you already have pagination, I think it's maybe 50 or 100 items, for the list views. It's the "PAGE_SIZE" value in the REST_FRAMEWORK settings. Ideally, depending what filters you offered it should substantially reduce the results in the API response. For example, I use your API to get the gcd issue id's using the following:
/api/series/name/Batman/issue/1/
Ideally, it would be nice to be able to do a query like this (or something similar) which should give only 1 result (providing it exists):
/api/issue/?series_id=1&number=1
Given the size of your DB being able to filter on things like
country, publisher, years, etc, should help with the response
sizes. If you'd like to see how I've implemented it, you can find
the code here:
https://github.com/Metron-Project/metron/tree/master/api
If you've got any questions, don't hesitate to ask.
Take care,
/B
@adam-knights pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@adam-knights pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()