Conversation
nfq2
left a comment
There was a problem hiding this comment.
i left a couple of comments for small fixes. also, since ur changing the database and adding a new table you need to add a migration (tells our database what changes it needs to make). u can prob just ask chatgpt how to do this since i'm not 100% what the commands are but try:
generate migration file: alembic revision --autogenerate -m "add <table>"
syncs ur DB and apply changes to ur db: alembic upgrade head
push the new changes it added to ur branch as well (migrations/versions)
you might also wanna do some testing by creating new challenges and seeing if you can get them using ur endpoint
|
Note: Because we are using a GraphQL API, we don't need a serialize function, as the serialization is implemented on a field-level in the |
|
|
||
|
|
||
|
|
||
| def downgrade(): |
| sa.PrimaryKeyConstraint('id') | ||
| ) | ||
|
|
||
|
|
| sa.Column('weekly_challenge_id', sa.Integer(), nullable=False), | ||
| sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True), | ||
| sa.Column('points', sa.Integer(), nullable=False), | ||
| sa.Column('status', sa.Enum('NOT_STARTED', 'IN_PROGRESS', 'COMPLETED', name='userweeklychallengestatusenum'), nullable=False, server_default='NOT_STARTED'), |
There was a problem hiding this comment.
line too long (176 > 120 characters)
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = '1063ea54c7b9' |
| sa.Column('rule_config', postgresql.JSONB(), nullable=True), | ||
| sa.Column('is_active', sa.Boolean(), nullable=False, server_default=sa.true()), | ||
| sa.Column('created_at', sa.DateTime(timezone=True), nullable=False, server_default=sa.text('CURRENT_TIMESTAMP')), | ||
| sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False, server_default=sa.text('CURRENT_TIMESTAMP'), onupdate=sa.text('CURRENT_TIMESTAMP')), |
There was a problem hiding this comment.
line too long (172 > 120 characters)
| status = Column(Enum(UserWeeklyChallengeStatus), nullable=False, default=UserWeeklyChallengeStatus.NOT_STARTED) | ||
| is_completed = Column(Boolean, nullable=False, default=False) | ||
|
|
||
| __table_args__ = (UniqueConstraint('user_id', 'weekly_challenge_id', name='unique_user_weekly_challenge'),) No newline at end of file |
| """ | ||
| __tablename__ = "user_weekly_challenges" | ||
|
|
||
| id = Column(Integer, primary_key = True, autoincrement = True) |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
| @@ -0,0 +1,27 @@ | |||
| from datetime import datetime | |||
| from sqlalchemy import Column, Integer, String, Date, DateTime, Enum, Boolean, ForeignKey, UniqueConstraint | |||
There was a problem hiding this comment.
'sqlalchemy.Date' imported but unused
'sqlalchemy.String' imported but unused
Black would make changes.
| @@ -0,0 +1,27 @@ | |||
| from datetime import datetime | |||
There was a problem hiding this comment.
'datetime.datetime' imported but unused
| is_active = Column(Boolean, nullable = False, default = True) | ||
|
|
||
| created_at = Column(DateTime(timezone=True), nullable = False, default=lambda: datetime.now(timezone.utc), server_default=text("CURRENT_TIMESTAMP")) | ||
| updated_at = Column(DateTime(timezone=True), nullable = False, default=lambda: datetime.now(timezone.utc), server_default=text("CURRENT_TIMESTAMP"), onupdate=lambda: datetime.now(timezone.utc)) No newline at end of file |
There was a problem hiding this comment.
no newline at end of file
unexpected spaces around keyword / parameter equals
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f0a42a5 to
860553a
Compare
| "start_date": self.start_date.isoformat(), | ||
| "end_date": self.end_date.isoformat() | ||
| } | ||
|
No newline at end of file |
There was a problem hiding this comment.
blank line at end of file
blank line contains whitespace
| end_date = Column (Date, nullable = False) | ||
|
|
||
|
|
||
| def serialize(self): |
| name = Column(String, nullable = False) | ||
| message = Column(String, nullable = False) | ||
| start_date = Column(Date, nullable = False) | ||
| end_date = Column (Date, nullable = False) |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
whitespace before '('
| id = Column(Integer, primary_key = True, autoincrement = True) | ||
| name = Column(String, nullable = False) | ||
| message = Column(String, nullable = False) | ||
| start_date = Column(Date, nullable = False) |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
|
|
||
| id = Column(Integer, primary_key = True, autoincrement = True) | ||
| name = Column(String, nullable = False) | ||
| message = Column(String, nullable = False) |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
| name = name, | ||
| message = message, | ||
| start_date = start_date, | ||
| end_date = end_date, |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
| new_challenge = WeeklyChallengeModel( | ||
| name = name, | ||
| message = message, | ||
| start_date = start_date, |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
| #Create new weekly challenge | ||
| new_challenge = WeeklyChallengeModel( | ||
| name = name, | ||
| message = message, |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
|
|
||
| #Create new weekly challenge | ||
| new_challenge = WeeklyChallengeModel( | ||
| name = name, |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
| if end_date <= start_date: | ||
| raise GraphQLError("End date must be after start date") | ||
|
|
||
| #Create new weekly challenge |
There was a problem hiding this comment.
block comment should start with '# '
Title
Added weekly_challenge table and query by date
Overview
Added table weekly_challenge.py in data base and added query get_weekly_challenge_by_date and added but commented out CreateWeeklyChallenge
Changes Made
I populated weekly_challenge table with name, message, start_date, and end_date, added serialize, and added query get_weekly_challenge_by_date
Test Coverage
Tested locally