Skip to content
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

Add a command to show the number of projects #969

Open
almet opened this issue Dec 20, 2021 · 15 comments
Open

Add a command to show the number of projects #969

almet opened this issue Dec 20, 2021 · 15 comments

Comments

@almet
Copy link
Member

almet commented Dec 20, 2021

I realized that I use a script since many years to get the emails and get some stats on the hosted instance, we probably could put it in a command instead!

# IHATEMONEY_SETTINGS_FILE_PATH=/home/ihatemoney/ihatemoney.org/ihatemoney.cfg ./ihatemoney.org/venv/bin/ihatemoney shell
>>> # To know the number of projects with more than 10 bills and less than 3 months old.
>>> from ihatemoney.models import *; import datetime
>>> projects = [pr for pr in Project.query.all() if pr.get_bills().count() > 10 and pr.get_bills()[0].date > datetime.date.today() - datetime.timedelta(days=90)]
>>> len(projects)
>>> # To get the email of the contacts
>>> ", ".join(set([pr.contact_email for pr in projects]))
@Skybova
Copy link

Skybova commented Oct 11, 2022

Hello, may I take look at this issue?

@almet
Copy link
Member Author

almet commented Oct 12, 2022

Sure thing, go ahead :-)

@ez157
Copy link
Contributor

ez157 commented Dec 7, 2022

Hi! My group and I from CMU are looking for issues to help out with! Could we get more clarification on what kind of command you want for this feature? Thanks :)

@almet
Copy link
Member Author

almet commented Dec 9, 2022

Hi, yes, please do :-) Commands are defined in https://github.com/spiral-project/ihatemoney/blob/master/ihatemoney/manage.py, you just need to add a new one :-) named get-project-count or something similar. Thanks!

@adammentzer
Copy link

Are all of the commands contained in manage.py?

@adammentzer
Copy link

like there's nothing else?

@almet
Copy link
Member Author

almet commented Dec 11, 2022

Yes :-)

@jjspill1
Copy link

I have been playing around with this feature request for a few days (also for a school project) and have yet to figure out where we want the functionality to occur. @almet by adding this to manage.py do you want to be able to run it through command script or as a button somewhere on the website.

Thank you for any insight!

@adammentzer
Copy link

adammentzer commented Dec 12, 2022

As a command for the command line using the Click library, which I have already done (and I'm also doing it for a school project haha). However, locally I have been having an issue where no matter what I do to manage.py nothing changes. As a test, I removed all of the code from manage.py and was still able to use all of the commands from command line, which is why I asked @almet if there is any other place that they are stored.

@jjspill1
Copy link

@adammentzer thats interesting, could you add your changes here so I may play around locally as well?

@almet
Copy link
Member Author

almet commented Dec 12, 2022

We don't need a button, just a command line tool is fine. If you're unable to make changes, ensure that you've installed the project by running the makefile, and also that you're following the steps in the docs. It seems that the copy you're using is not installed.

You might want to follow the guide from the beginning to ensure it's installed properly.

@jjspill1
Copy link

@almet I have gotten the command line to work in manage.py and now am trying to add some simple test cases. Right now, I am having a problem creating databases and then have the script in manage.py recognize them, do you have an idea why that may be? Do you think this section of code should have a corresponding test case? Thank you!

@adammentzer
Copy link

@almet to the best of my knowledge that's what i've done, i followed them all step by step

@adammentzer
Copy link

i had an issue with configuration and /etc/ file permissions but i've resolved it...i think

@jjspill1
Copy link

I have submitted a PR request here for this feature request: #1115. If anyone has suggestions let me know.

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

No branches or pull requests

5 participants