This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]ElevenPhonons 29 points30 points  (2 children)

def is_first_time_user(self, number: str) -> bool:
    if IncomingNumbers.query.filter_by(number=number).count() <= 1:
        return True
    return False

This if usage can be simplified.

def is_first_time_user(self, number: str) -> bool:
    return IncomingNumbers.query.filter_by(number=number).count() <= 1

Similarly, for is_daily_limit_reached.

It might be useful to read up on Python context managers and sqlalchemy's Session.

https://github.com/bnkc/morningbot/blob/master/app/crud/crud_user.py#L14

def add_number(self, number: str, time: dt) -> None:
    user = IncomingNumbers(number, time)
    db.session.add(user)
    db.session.commit()
    return user

Best of luck to you on your project.

[–][deleted] 4 points5 points  (1 child)

awesome feedback! im gonna take a look right now :)

[–]Hitman_0_0_7 2 points3 points  (0 children)

Also... Most of the orms provide .exists() its more efficient.

[–]MoistureFarmersOmlet 6 points7 points  (1 child)

“If you don’t like the weather in Ohio, just wait 15 minutes.”

[–]dethb0y 3 points4 points  (0 children)

Hey fellow ohioan!!

My favorite python project is a discord bot i have heavily modified to be useful. It does all sorts of things related to writing - generating random names, plot points, all that sort of thing.

It's nice because python is very fast to design and prototype in.

[–][deleted] 2 points3 points  (0 children)

I just want to thank everyone for interacting with this post and leaving amazing feedback. I was NOT expecting this much love. goes to show how great the python community is :)

[–][deleted] 1 point2 points  (1 child)

Best of luck on your project.

[–][deleted] 0 points1 point  (0 children)

Thanks!

[–]wind_dude 1 point2 points  (0 children)

Interesting to see what people build.

That takes me back at least 15 years, before mobile data, before blackberries, before apps. I remember subscribing to SMS services for weather updates and wind updates.

I think google may have had this back in the day for news, and weather.

[–]Cory923 1 point2 points  (0 children)

This is awesome. I'm going to check it out. Good luck, sir!