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

feat: new active projects api for export tool #6153

Merged
merged 6 commits into from
Jan 8, 2024

Conversation

kaditya97
Copy link
Member

New endpoint to generate a list of active projects

endpoint: /projects/queries/active/
query parameter:

500:
description: Internal Server Error
"""
interval = int(request.args.get("interval", 24))
Copy link
Member

Choose a reason for hiding this comment

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

We need to add validation for the interval


@staticmethod
def get_active_projects(interval):
action_date = datetime.now() - timedelta(hours=interval)
Copy link
Member

Choose a reason for hiding this comment

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

I assume datetime.now() is in UTC ?

default: Token sessionTokenHere==
- name: interval
in: path
description: Time interval to get active project
Copy link
Member

Choose a reason for hiding this comment

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

time interval in hours

Copy link
Member

@kshitijrajsharma kshitijrajsharma left a comment

Choose a reason for hiding this comment

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

Good overall changes added slight comment on end validation ! Cheers

@@ -1197,6 +1197,9 @@ def get(self):
500:
description: Internal Server Error
"""
interval = int(request.args.get("interval", 24))
interval = request.args.get("interval", "24")
if not interval.isdigit():
Copy link
Member

Choose a reason for hiding this comment

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

0 and <=24 restrict user to extract more than 24 hour active projects

result = (
TaskHistory.query.with_entities(TaskHistory.project_id)
.distinct()
.filter(TaskHistory.action_date >= action_date)
Copy link
Member

Choose a reason for hiding this comment

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

Using this , test this query with dump of production database , you might need action_date btree timestamp index

@kshitijrajsharma
Copy link
Member

@kaditya97 Can you make sure that backend tests are passing ?

Copy link

sonarcloud bot commented Jan 8, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

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

See analysis details on SonarCloud

@kshitijrajsharma kshitijrajsharma merged commit af75feb into develop Jan 8, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export tool integration: Creating a new endpoint to generate a list of active projects
2 participants