Skip to content

SAK-51413 webapi add endpoints to retrieve assessment scheduled data #13651

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jumarub
Copy link
Contributor

@jumarub jumarub commented Apr 24, 2025


// Main query to retrieve site data using date range and limit/offset for pagination
// The parameters returned are SITE_ID, TITLE, CREATEDON, MODIFIEDON, and SOFTLY_DELETED_DATE
String query = "SELECT SITE_ID, TITLE, CREATEDON, MODIFIEDON, SOFTLY_DELETED_DATE " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the site service for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using site service and the getSites() method can we retrieve the sites using createdon and modifiedon dates?

Copy link
Contributor

Choose a reason for hiding this comment

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

this all looks like custom code to me! we do the same thing for clients. but we keep the custom code out of the sakaiproject/sakai branches. we just maintain it separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes @ottenhoff, this was a custom development, but they asked us if we could contribute these new changes, we think that it's a good thing that we could retrieve data like sites, assessments or memberships using date parameters

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, it would be fine in master! But it's going to be a lot of work to change all of this raw SQL to use the proper Sakai services!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with date parameters being added to the site service api layer, but that is what needs to happen before this is even considered for master. That's my opinion and other people may disagree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah of course I agree! Every tool needs to use siteService

@Autowired
private UserDirectoryService userDirectoryService;

@GetMapping(value = "/assessment/scheduled", produces = MediaType.APPLICATION_JSON_VALUE)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is Samigo stuff, it should not be in the SitesController.

conn.setReadOnly(true);

// Set date parameters and retrieve total elements
countPs = conn.prepareStatement(countQuery);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to do raw JDBC code in Sakai. We have the sqlService and Hibernate. Hibernate is the way to do it. And, generally, you should do db code in backend service and make sure to write unit tests for it.

Copy link
Contributor

@ern ern Apr 24, 2025

Choose a reason for hiding this comment

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

Completely agree putting in raw jdbc code bypasses hibernate, you should fetch this information using the service

Copy link
Contributor Author

@jumarub jumarub Apr 30, 2025

Choose a reason for hiding this comment

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

Could you please check the last commit?
3edb369

Should be done like that? Thanks a lot for the suggestions :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@adrianfish adrianfish May 5, 2025

Choose a reason for hiding this comment

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

You need to use the kernel's siteService to get this data. You should not be writing queries onto the site database directly like this. We write our db logic in one place and use an api to access it. That way we only have to update DDL statements in one place. You will see that pattern all across the Sakai codebase, one definition of SQL calls and an API to access those database calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know we could use the siteService for retrieving the sites data, but as far as I can see we cannot filter the sites using the createdon and modifiedon dates

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, add logic to SiteService to handle those dates. Update the API and keep the db logic contained.

@ern ern changed the title SAK-51413 New API endpoints for retrieve scheduled data SAK-51413 webapi add endpoints to retrieve assessment scheduled data Apr 24, 2025
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