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

Expire maintainer invites and scheduled tasks for the database #1221

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

ewan-escience
Copy link
Collaborator

Expire maintainer invites and scheduled tasks for the database

Changes proposed in this pull request:

  • Maintainer invites now expire 31 days after creation; this is implemented by an automatically generated column in the database
  • Show the remaining validity of invites in days on the frontend
  • Add documentation on how to schedule repeated tasks in the database

How to test:

  • docker compose down --volumes && docker compose build --parallel && docker compose up --scale data-generation=1
  • Sign in as admin, create maintainer invites for a software page, project and organisation
  • Each invitation should show that it will expire in 31 days
  • You can run the following snippet in the database to experiment with different expiration dates for software invites to check if the frontend behaves correctly:
ALTER TABLE invite_maintainer_for_software DISABLE TRIGGER sanitise_update_invite_maintainer_for_software;
UPDATE invite_maintainer_for_software SET created_at = CURRENT_TIMESTAMP - INTERVAL '31 days';
ALTER TABLE invite_maintainer_for_software ENABLE TRIGGER sanitise_update_invite_maintainer_for_software;
  • Check the updated docs on this
  • Check the new section here on running repeated tasks
  • Optional: you could run a cron job similar to the ones in the docs by adding the following line to your crontab, make sure to edit the paths
* * * * * docker-compose --file /home/ubuntu/docker-compose.yml exec -T database psql --dbname=rsd-db --username=rsd --command="SELECT COUNT(*) FROM software;" >> /home/ubuntu/cron.log 2>&1

Closes #260

PR Checklist:

  • Increase version numbers in docker-compose.yml
  • Link to a GitHub issue
  • Update documentation
  • Tests

@ewan-escience ewan-escience self-assigned this Jun 5, 2024
Copy link

sonarqubecloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed for 'rsd-database'

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

sonarqubecloud bot commented Jun 5, 2024

Copy link
Contributor

@dmijatovic dmijatovic left a comment

Choose a reason for hiding this comment

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

Nice work!

Copy link
Contributor

@cmeessen cmeessen left a comment

Choose a reason for hiding this comment

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

Works as described.

Would it be possible to install cron in the Postgres container so that we can add the scheduled task in the container?

@ewan-escience
Copy link
Collaborator Author

Would it be possible to install cron in the Postgres container so that we can add the scheduled task in the container?

We decided on investigating having a dedicated container for cron jobs.

About the 31 day, it is not allowed to use a subquery in a generated column, so we cannot use any env variables to change it. I'm fine with changing it to another value, like 14 days, but I don't think it's possible to make it configurable. You can of yourse change the column manually on your instance.

@ewan-escience ewan-escience merged commit e74c1d2 into main Jun 10, 2024
6 checks passed
@ewan-escience ewan-escience deleted the 260-maintainer-invitation-improvements branch July 23, 2024 08:38
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.

Maintainer flow improvements
3 participants