Skip to content

Feature/time coordinator #297

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8ac8717
Branch transfer, stage 1
Feb 15, 2021
201258d
<feat>[updated_edition]: <Allows displaying chosen meeting by country>
Feb 15, 2021
a8acf1a
with the test coverage fixed
Feb 15, 2021
966a929
few changes before creating a pull request
Feb 15, 2021
10bbe14
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 15, 2021
c618f50
with flake8 fixes: number 1
Feb 15, 2021
42b2d07
Merge branch 'feature/time-coordinator' of https://github.com/TamarBe…
Feb 15, 2021
5b3702a
with flake8 fixes: number 2
Feb 15, 2021
5225174
with flake8 fixes: number 3
Feb 15, 2021
4493a18
with flake 8 fixes: number 4
Feb 15, 2021
60b48a3
with flake8 fixes: number 5
Feb 15, 2021
0a11711
with flake8 fixes: number 6
Feb 15, 2021
f05283d
with flake8 fixes: number 7
Feb 15, 2021
2d9a98d
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 15, 2021
ec20bdb
with pip freeze>requirements.txt
Feb 15, 2021
f35c3dc
Merge branch 'feature/time-coordinator' of https://github.com/TamarBe…
Feb 15, 2021
ad8e5c1
with pytest fixes: number 1
Feb 15, 2021
007bc6c
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 16, 2021
6cf06bb
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 20, 2021
4ec84d1
Merge branch 'develop' of https://github.com/PythonFreeCourse/calenda…
Feb 21, 2021
b85b201
second commit for hooks
Feb 22, 2021
d0c22b9
Trying to save the initial JS version
Feb 22, 2021
36f3aeb
with the javascrips transition
Feb 23, 2021
e2a5f74
with fixes according to Yam's review (as JS)
Feb 23, 2021
e384b3c
with changes according to Yam's and Inbal's review
Feb 23, 2021
fcc771a
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 23, 2021
5e86378
with the dependency error fix
Feb 23, 2021
a0ca780
with the js change and the fixed tests
Feb 24, 2021
79aab43
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 24, 2021
3f41ec4
Hopefully with last fixes
Feb 24, 2021
fdb116c
Merge branch 'develop' into feature/time-coordinator
TamarBerger Feb 24, 2021
89d83ef
flake8 fixes : hopefully last
Feb 24, 2021
b6caf87
with some changes according to Yam's review
Feb 25, 2021
269dab1
with changes according to Yam's review
Feb 25, 2021
f378cbc
with conflicts solved and isort installed
Feb 25, 2021
9b66a62
with updated app.config and req imports
Feb 25, 2021
8975f68
with DOMContentLoaded and session.merge
Feb 25, 2021
26ff987
with DOMContentLoaded fixed
Feb 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ class Quote(Base):
author = Column(String)


class Country(Base):
__tablename__ = "countries"

id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False, unique=True)
timezone = Column(String, nullable=False)


class Comment(Base):
__tablename__ = "comments"

Expand Down
41 changes: 40 additions & 1 deletion app/internal/event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import logging
import re
from typing import List, NamedTuple, Set, Union
Expand All @@ -11,7 +12,8 @@
from sqlalchemy.orm import Session
from starlette.status import HTTP_400_BAD_REQUEST

from app.database.models import Event
from app.database.models import Country, Event
from app.resources.countries import countries

ZOOM_REGEX = re.compile(r"https://.*?\.zoom.us/[a-z]/.[^.,\b\s]+")

Expand Down Expand Up @@ -114,6 +116,43 @@ def get_messages(
return messages


def add_countries_to_db(session: Session) -> None:
"""
Adding all new countries to the "Country" table in the database.
Information is based on the "countries" list.
(The list is located in app/resources/countries.py)
Names are described either as:
"Country Name, City Name" or
"Country Name" solely.
Timezones are described as "Continent/ City Name"
for example:
name: Israel, Jerusalem
timezone: Asia/Jerusalem
"""
for country in countries:
partial_name = country["name"]
for capital_city in country["timezones"]:
capital_city_name = capital_city.split("/")[-1]
if partial_name != capital_city_name:
name = partial_name + ", " + capital_city_name
else:
name = capital_city_name
new_country = Country(name=name, timezone=str(capital_city))
session.merge(new_country)
session.commit()


@functools.lru_cache
def get_all_countries_names(session: Session) -> List[str]:
"""
Returns a cached list of the countries names.
"""
db_entity = session.query(Country).first()
if not db_entity:
add_countries_to_db(session=session)
return session.query(Country.name).all()


async def get_location_coordinates(
address: str,
) -> Union[Location, str]:
Expand Down
Loading