Skip to content

Pr country search #5

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rampmaster
Copy link
Contributor

Implementation of the country search strategy by its ISO code.
The environment variables are reincorporated into the main function, so constructors are refactored to support the step in that method
The data retrieval functions of the vTools Events API are transformed into an object

@rampmaster rampmaster marked this pull request as draft March 31, 2025 02:48
@rampmaster rampmaster marked this pull request as ready for review March 31, 2025 02:50
Copy link
Owner

@Crola1702 Crola1702 left a comment

Choose a reason for hiding this comment

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

Some of these changes look great. However, they don't belong to this PR, instead, they should be on different PRs such as: "Use calendar_id as parameter for CalendarAPI", and "Refactor vtools_fetcher to EventFetcher class`.

@@ -1,4 +1,4 @@
VTOOLS_API="https://events.vtools.ieee.org/RST/events/api/public/<vtools_event_api_version>/"
CALENDAR_ID="<google_calendar_collab_email>"
COUNTRY_ID=<vtools_events_country_id>
FILTER_MODE="COUNTRY"
COUNTRY_CODE="<ISO_3166-1_alpha-2_code>"
Copy link
Owner

Choose a reason for hiding this comment

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

This implementation is making me thing we should instead look for arguments instead of environment variables. I.e., running the script with -c <country_id> or --country-code <iso-code>.

Copy link
Owner

Choose a reason for hiding this comment

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

This change looks excellent. However, it doesn't belong to this PR (the changes are scoped to Country search instead). Please create a PR with this changes instead

Copy link
Owner

Choose a reason for hiding this comment

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

Same comments as above. This should not be a PR for refactors, but instead a PR for country search.

Comment on lines +8 to +28
vtf = EventFetcher(base_url=os.getenv('VTOOLS_API'))

country_code = os.getenv('COUNTRY_CODE')

# TODO: Create exception class for this error
if country_code is None:
raise Exception()

country_code = country_code.upper()
country_id = None
countries = vtf.fetch_countries()
for country in countries:
id = country['id']
abbreviation = country['attributes']['abbreviation']
if abbreviation == country_code:
country_id = id
break

# TODO: Create exception class for this error
if country_id is None:
raise Exception()
Copy link
Owner

Choose a reason for hiding this comment

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

What I don't like about this is the inability to use the country_id instead. I would prefer to have COUNTRY_CODE as an override argument for it.

Or even to have a cached variable with country id when looking for the country code.

Comment on lines +8 to +28
vtf = EventFetcher(base_url=os.getenv('VTOOLS_API'))

country_code = os.getenv('COUNTRY_CODE')

# TODO: Create exception class for this error
if country_code is None:
raise Exception()

country_code = country_code.upper()
country_id = None
countries = vtf.fetch_countries()
for country in countries:
id = country['id']
abbreviation = country['attributes']['abbreviation']
if abbreviation == country_code:
country_id = id
break

# TODO: Create exception class for this error
if country_id is None:
raise Exception()
Copy link
Owner

Choose a reason for hiding this comment

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

What I don't like about this is the inability to use the country_id instead. I would prefer to have COUNTRY_CODE as an override argument for it.

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.

2 participants