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 search history settings #1201

Merged
merged 38 commits into from
Oct 19, 2023
Merged

add search history settings #1201

merged 38 commits into from
Oct 19, 2023

Conversation

lukavdplas
Copy link
Contributor

Adds a settings screen where users can configure whether to enable search history, or delete their existing history. Close #1145

@lukavdplas lukavdplas added the enhancement improvements to user functionality label Jul 19, 2023
@lukavdplas lukavdplas force-pushed the feature/privacy-settings-1 branch from de1d88e to c6f4236 Compare August 15, 2023 11:22
Copy link
Contributor

@JeltevanBoheemen JeltevanBoheemen left a comment

Choose a reason for hiding this comment

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

Well done @lukavdplas

Depending on your opinion, this is either an approve or a request changes :)

I would rather not see the merging of User and UserProfile in the frontend, but keep profile as a separate class on a User. I (think) I can follow your reasons, and also find them valid.

backend/users/admin.py Show resolved Hide resolved
backend/users/apps.py Outdated Show resolved Hide resolved
@@ -18,3 +18,20 @@ def has_access(self, corpus_name):
# check if any corpus added to the user's group(s) match the corpus name
return any(corpus for group in self.groups.all()
for corpus in group.corpora.filter(name=corpus_name))


class UserProfile(models.Model):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class UserProfile(models.Model):
class UserProfile(models.Model):
''' User information that is not relevant to authentication.
E.g. settings, preferences, optional personal information.
'''

backend/users/serializers.py Show resolved Hide resolved
Comment on lines 34 to 37
if created:
UserProfile.objects.get_or_create(
user=instance
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This combination makes no sense. If a User is created, there should not be a UserProfile because it's a 1-to-1 relation. Cases where the get part is executed instead are clear bugs and should not be passed silently.

Suggested change
if created:
UserProfile.objects.get_or_create(
user=instance
)
if created:
UserProfile.objects.create(user=instance)

Comment on lines 46 to 52
let resultsPromise: Promise<SearchResults>;

if (user.enableSearchHistory) {
resultsPromise = this.searchAndSave(queryModel, user, request);
} else {
resultsPromise = request();
}
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 not always a fan of ternary operator, but here it saves a lot of lines. Feel free to ignore.

Suggested change
let resultsPromise: Promise<SearchResults>;
if (user.enableSearchHistory) {
resultsPromise = this.searchAndSave(queryModel, user, request);
} else {
resultsPromise = request();
}
const resultPromise: Promise<SearchResults> = user.enableSearchHistory ?
this.searchAndSave(queryModel, user, request) : request();

frontend/src/app/services/search.service.ts Show resolved Hide resolved
Comment on lines 8 to 13
export class SearchHistorySettingsComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiniest hill to die on.

Suggested change
export class SearchHistorySettingsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
export class SearchHistorySettingsComponent {
constructor() { }

templateUrl: './settings.component.html',
styleUrls: ['./settings.component.scss']
})
export class SettingsComponent implements OnInit {
Copy link
Contributor

Choose a reason for hiding this comment

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

Another hill!

@lukavdplas
Copy link
Contributor Author

I would rather not see the merging of User and UserProfile in the frontend, but keep profile as a separate class on a User. I (think) I can follow your reasons, and also find them valid.

Fair enough, I wasn't sure about this myself. I would like these to be handled in a single view, but UserProfile can also just be included as a nested model.

@lukavdplas
Copy link
Contributor Author

I would rather not see the merging of User and UserProfile in the frontend, but keep profile as a separate class on a User. I (think) I can follow your reasons, and also find them valid.

Fair enough, I wasn't sure about this myself. I would like these to be handled in a single view, but UserProfile can also just be included as a nested model.

Ah, I remembered the implementation incorrectly, so this reply makes no sense. It's already nested.

I can see the merit of having one view for authentication and one for user information, but the current implementation already merges those. I'm not sure that separation should be included in this PR.

@lukavdplas lukavdplas merged commit 19d44f2 into develop Oct 19, 2023
@lukavdplas lukavdplas deleted the feature/privacy-settings-1 branch October 19, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements to user functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make search history opt-in
2 participants