Skip to content

Conversation

@ramoniee
Copy link
Contributor

@ramoniee ramoniee commented Apr 18, 2024

Related issues: [please specify]

Description:

What are you up to? Fill us in :)

Screenshots/videos

I solemnly swear that:

  • My code follows the style guidelines of this project
  • I have merged the develop branch into my branch and fixed any merge conflicts
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have tested new or existing tests and made sure that they pass


def get_duration_from_course_component(course_component):
if course_component.agile_card.status in [
models.AgileCard.BLOCKED,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some things wont have cards. Expecting to have cards will mean they break some of the time.

Just use the times. We dont need to query the database for related objects.

Here is the code:

def get_duration(self):
    if self.start_time == None:
          return timedelta(0)
    if self.end_time == None:
          return timezone.now() - self.start_time
    eturn self.end_time - self.start_time

Notice the use of self. And the name of the function. These are intentional.

return self.agile_card.status

def get_duration(self):
return helpers.get_duration_from_course_component(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather make a base class and inherit the functionality.

class get_duration_Tests(TestCase):

def make_project_card(self, status):
self.card = factories.AgileCardFactory(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this getting complicated again?

Why are cards here at all?

Write loosely coupled code. Dont write code that relied on things it doesn't need. This stuff will break.

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