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

[#3107]Implement script for splitting assignments between surveys. #3121

Merged
merged 5 commits into from
Jun 20, 2019

Conversation

stellanl
Copy link
Contributor

Before the PR (what is the issue or what needed to be done)

Assignments must not contain forms from different surveys.

The solution

Datascript to split them.

Screenshots (if appropriate)

Checklist

  • Test plan
  • Copyright header
  • Code formatting
  • Documentation

@stellanl stellanl requested a review from muloem June 18, 2019 11:37
Copy link
Member

@muloem muloem left a comment

Choose a reason for hiding this comment

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

As a general comment, I was just thinking that maybe its going to be saving the constant pinging to the backend if you retrieve all the SurveyGroup and Survey entities before starting with the splitting up. That way you have all the relationships, names etc upfront rather than pinging the datastore from within a for loop. that usually slows things down.

System.out.println("Splitting assignment " + id + " into " + surveys.size());

int part = 0;
for (List<Long> f: surveys.values()) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (List<Long> f: surveys.values()) {
for (List<Long> formsList: surveys.values()) {

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 actually never thought the assignments were numerous enough to deserve optimisation...

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 reused those methods from another datascript, to save time and testing.

Copy link
Member

Choose a reason for hiding this comment

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

True there are probably not that many. (400 on some of the larger instances). it still makes the communication with the datastore very chatty which is considered an anti-pattern for datastore access at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done. I still think reimplementing it took longer that running it would have...

if (++part == 1) { //change it
toBeSaved.add(ass);
System.out.println(" changing from " + ass);
ass.setProperty("name", name + " [" + part + "]");
Copy link
Member

Choose a reason for hiding this comment

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

Do you think its an idea to have the part use partially or fully the survey name? That may be clearer than just having a number.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@stellanl stellanl changed the title [#3107]Implement script for splitting assignments betwen surveys. [#3107]Implement script for splitting assignments between surveys. Jun 20, 2019
@stellanl stellanl merged commit ade6eb0 into develop Jun 20, 2019
@stellanl stellanl deleted the issue/3107-script-for-splitting-assignments branch June 20, 2019 10:31
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.

2 participants