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

[Feature] Improve the search_owner when query the app list #1828

Merged
merged 8 commits into from
Oct 15, 2022
Merged

[Feature] Improve the search_owner when query the app list #1828

merged 8 commits into from
Oct 15, 2022

Conversation

wolfboys
Copy link
Member

[Feature] Improve the search_owner when query the app list

Contribution Checklist

  • If this is your first time, please read our contributor guidelines: Submit Code.

  • Make sure that the pull request corresponds to a GITHUB issue.

  • Name the pull request in the form "[Feature] Title of the pull request", where Feature can be replaced by Hotfix, Bug, etc.

  • Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.

  • If the PR is unfinished, add [WIP] in your PR title, e.g., [WIP][Feature] Title of the pull request.

-->

What changes were proposed in this pull request

Issue Number: close #1827

Brief change log

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): (yes / no)

@wolfboys
Copy link
Member Author

@1996fanrui PTAL

@1996fanrui
Copy link
Member

Hi @wolfboys , I have a question.

There are some applications belong to admin. Should we show all app owner for current team?

4FE099D9-4168-4B71-AF53-BFC098FA0BEA

@1996fanrui
Copy link
Member

Hi @wolfboys , I have a question.

There are some applications belong to admin. Should we show all app owner for current team?

4FE099D9-4168-4B71-AF53-BFC098FA0BEA

In other word, if user_a is admin, he doesn't belong to team1, and he has some apps in team1, should we show the user_a here?

If user_b isn't admin. he belongs to team1. He doesn't have any apps. Should we show user_b here?

@wolfboys
Copy link
Member Author

In other word, if user_a is admin, he doesn't belong to team1, and he has some apps in team1, should we show the user_a here?

if usertype is admin, the range of users: Himself + members of the team

If user_b isn't admin. he belongs to team1. He doesn't have any apps. Should we show user_b here?

yes

@wolfboys
Copy link
Member Author

hi fanrui:

In other word, if user_a is admin, he doesn't belong to team1, and he has some apps in team1, should we show the user_a here?

if usertype is admin, the range of users: Himself (has app) + members of the team (members has least one app)

If user_b isn't admin. he belongs to team1. He doesn't have any apps. Should we show user_b here?

yes, but user_b must be has least one app, else no.

Comment on lines 70 to 89
select u.* from t_user u
inner join (
select distinct(user_id) as user_id from (
select a.user_id
from t_user a
inner join t_flink_app b
on a.user_id = b.user_id
where a.user_id = #{userId}
and a.user_type = 1
union all
select u.user_id
from t_user u
inner join t_member m
on u.user_id = m.user_id
inner join t_flink_app p
on u.user_id = p.user_id
where m.team_id = #{teamId}
)
) as t
where u.user_id = t.user_id
Copy link
Member

Choose a reason for hiding this comment

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

Why don't use this sql?

select u.* from t_user u 
inner join (
select distinct(user_id) from t_flink_app where m.team_id = #{teamId}
) t
where u.user_id = t.user_id

The new sql has some advantages:

  • It is more simple.
  • It is easy to understand for other developers.
  • And it can show all apps owner for current team.
  • When some team members leave or move to other teams, we should also be able to filter his apps.
  • For the System Admin team, Admins often have some test jobs. AdminA should be able to filter AdminB's apps.

The new sql is simple and feature rich, why use a complex sql?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why don't use this sql?

select u.* from t_user u 
inner join (
select distinct(user_id) from t_flink_app where m.team_id = #{teamId}
) t
where u.user_id = t.user_id

The new sql has some advantages:

  • It is more simple.
  • It is easy to understand for other developers.
  • And it can show all apps owner for current team.
  • When some team members leave or move to other teams, we should also be able to filter his apps.
  • For the System Admin team, Admins often have some test jobs. AdminA should be able to filter AdminB's apps.

The new sql is simple and feature rich, why use a complex sql?

oh, Perfect 👍 😂

1996fanrui
1996fanrui previously approved these changes Oct 14, 2022
Copy link
Member

@1996fanrui 1996fanrui left a comment

Choose a reason for hiding this comment

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

Hi @wolfboys , LGTM, thanks for your great contribution.

Hi @lvshaokang @MonsterChenzhuo , please help double check, thanks.

@@ -102,4 +102,9 @@ public class User implements Serializable {
*/
private Long teamId;

public void dataMasking() {
this.setPassword("******");
Copy link
Contributor

Choose a reason for hiding this comment

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

hi, @wolfboys Thank you for your contribution。Strings with special meanings are recommended to be extracted as public variables,do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

hi, @wolfboys Thank you for your contribution。Strings with special meanings are recommended to be extracted as public variables,do you think?

Great suggestion, I agree with you. I'll fix it later

Copy link
Contributor

@monrg monrg left a comment

Choose a reason for hiding this comment

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

LGTM

@monrg monrg merged commit be6e842 into apache:dev Oct 15, 2022
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.

[Feature] Improve the search_owner when query the app list
3 participants