Skip to content

Tran/set up weekly challenges - #225

Open
tnt07-t wants to merge 3 commits into
masterfrom
tran/set-up-weekly-challenges
Open

tnt07-t wants to merge 3 commits into
masterfrom
tran/set-up-weekly-challenges

Conversation

@tnt07-t

@tnt07-t tnt07-t commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

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

@tnt07-t
tnt07-t requested review from Aayush-Agnihotri, akmatchev and nfq2 and removed request for Aayush-Agnihotri November 25, 2025 03:58

@nfq2 nfq2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread requirements.txt
Comment thread src/schema.py Outdated
@cejiogu

cejiogu commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

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 schema.py file




def downgrade():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (4)

sa.PrimaryKeyConstraint('id')
)


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blank line contains whitespace

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'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (176 > 120 characters)



# revision identifiers, used by Alembic.
revision = '1063ea54c7b9'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Black would make changes.

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')),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (172 > 120 characters)

Comment thread src/models/user_weekly_challenges.py Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file

Comment thread src/models/user_weekly_challenges.py Outdated
"""
__tablename__ = "user_weekly_challenges"

id = Column(Integer, primary_key = True, autoincrement = True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/models/user_weekly_challenges.py Outdated
@@ -0,0 +1,27 @@
from datetime import datetime
from sqlalchemy import Column, Integer, String, Date, DateTime, Enum, Boolean, ForeignKey, UniqueConstraint

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'sqlalchemy.Date' imported but unused
'sqlalchemy.String' imported but unused
Black would make changes.

Comment thread src/models/user_weekly_challenges.py Outdated
@@ -0,0 +1,27 @@
from datetime import datetime

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'datetime.datetime' imported but unused

Comment thread src/models/weekly_challenge.py Outdated
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no newline at end of file
unexpected spaces around keyword / parameter equals

@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cde9df77-f1ab-4bd3-aba9-5ef48d8bcb99


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cejiogu
cejiogu force-pushed the tran/set-up-weekly-challenges branch from f0a42a5 to 860553a Compare September 23, 2026 22:31
"start_date": self.start_date.isoformat(),
"end_date": self.end_date.isoformat()
}

No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blank line at end of file
blank line contains whitespace

end_date = Column (Date, nullable = False)


def serialize(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too many blank lines (2)

name = Column(String, nullable = False)
message = Column(String, nullable = False)
start_date = Column(Date, nullable = False)
end_date = Column (Date, nullable = False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals


id = Column(Integer, primary_key = True, autoincrement = True)
name = Column(String, nullable = False)
message = Column(String, nullable = False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/schema.py
name = name,
message = message,
start_date = start_date,
end_date = end_date,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/schema.py
new_challenge = WeeklyChallengeModel(
name = name,
message = message,
start_date = start_date,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/schema.py
#Create new weekly challenge
new_challenge = WeeklyChallengeModel(
name = name,
message = message,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/schema.py

#Create new weekly challenge
new_challenge = WeeklyChallengeModel(
name = name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

Comment thread src/schema.py
if end_date <= start_date:
raise GraphQLError("End date must be after start date")

#Create new weekly challenge

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

block comment should start with '# '

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.

4 participants