This is an automated email from the ASF dual-hosted git repository.
chenli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new 27b86aaca4 fix: Removing unnecessary user info returned from the
backend (#4138)
27b86aaca4 is described below
commit 27b86aaca4e9e68136903d32e35faabfde26983f
Author: carloea2 <[email protected]>
AuthorDate: Mon Dec 29 10:26:55 2025 -0800
fix: Removing unnecessary user info returned from the backend (#4138)
### What changes were proposed in this PR?
Currently the endpoint `/api/workflow/owner_user/?wid=X` returns all the
information about the user, including name, email, etc. But the frontend
only needs the name. This PR limits the information returned from the
backend to the user name only.
The main changes are as follow:
1. Change the endpoint name from `/api/workflow/owner_user` to
`/api/workflow/owner_name`
2. Change the SQL query to only return name as plain text.
3. Change related uses of the endpoint in the frontend to match the new
signature.
4. Added a new `WorkflowResourceDashboardUserSpec` to test this endpoint
and support future testing of related endpoints.
### Any related issues, documentation, discussions?
No
### How was this PR tested?
Tests:
<img width="1778" height="429" alt="image"
src="https://github.com/user-attachments/assets/81b91d73-7396-4d97-a53f-80d4ed5ca724"
/>
Manually tested:
<img width="1348" height="658" alt="image"
src="https://github.com/user-attachments/assets/1aeba8b4-343c-407f-b1ef-ffc5b4afee1a"
/>
### Was this PR authored or co-authored using generative AI tooling?
No
---
.../dashboard/user/workflow/WorkflowResource.scala | 23 ++++++++--------------
.../dashboard/file/WorkflowResourceSpec.scala | 17 ++++++++++++++++
.../workflow-persist/workflow-persist.service.ts | 11 +++++------
.../detail/hub-workflow-detail.component.ts | 6 +++---
4 files changed, 33 insertions(+), 24 deletions(-)
diff --git
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala
index 4248d06bdd..45ed49a23d 100644
---
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala
+++
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala
@@ -712,23 +712,16 @@ class WorkflowResource extends LazyLogging {
}
@GET
- @Path("/owner_user")
- def getOwnerUser(@QueryParam("wid") wid: Integer): User = {
+ @Produces(Array(MediaType.TEXT_PLAIN))
+ @Path("/owner_name")
+ def getOwnerName(@QueryParam("wid") wid: Integer): String = {
context
- .select(
- USER.UID,
- USER.NAME,
- USER.EMAIL,
- USER.PASSWORD,
- USER.GOOGLE_ID,
- USER.ROLE,
- USER.GOOGLE_AVATAR
- )
- .from(WORKFLOW_OF_USER)
- .join(USER)
- .on(WORKFLOW_OF_USER.UID.eq(USER.UID))
+ .select(USER.NAME)
+ .from(USER)
+ .join(WORKFLOW_OF_USER)
+ .on(USER.UID.eq(WORKFLOW_OF_USER.UID))
.where(WORKFLOW_OF_USER.WID.eq(wid))
- .fetchOneInto(classOf[User])
+ .fetchOneInto(classOf[String])
}
@GET
diff --git
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
index 3aa9b78d86..74a68ee65e 100644
---
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
+++
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala
@@ -300,6 +300,23 @@ class WorkflowResourceSpec
)
}
+ "WorkflowResource /owner_name" should "return owner name as plain text" in {
+ workflowResource.persistWorkflow(testWorkflow1, sessionUser1)
+
+ val workflows =
workflowResource.retrieveWorkflowsBySessionUser(sessionUser1)
+ assert(workflows.nonEmpty)
+
+ val wid =
+ workflows
+ .find(_.workflow.getName == testWorkflow1.getName)
+ .map(_.workflow.getWid)
+ .getOrElse(workflows.head.workflow.getWid)
+
+ val ownerName = workflowResource.getOwnerName(wid)
+
+ assert(ownerName == testUser.getName)
+ }
+
"/search API " should "be able to search for workflows in different columns
in Workflow table" in {
// testWorkflow1: {name: test_name, descrption: test_description, content:
test_content}
// search "test_name" or "test_description" or "test_content" should
return testWorkflow1
diff --git
a/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts
b/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts
index 8f629d5da4..5e738c5add 100644
---
a/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts
+++
b/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts
@@ -41,7 +41,7 @@ export const WORKFLOW_UPDATENAME_URL = WORKFLOW_BASE_URL +
"/update/name";
export const WORKFLOW_UPDATEDESCRIPTION_URL = WORKFLOW_BASE_URL +
"/update/description";
export const WORKFLOW_OWNER_URL = WORKFLOW_BASE_URL + "/user-workflow-owners";
export const WORKFLOW_ID_URL = WORKFLOW_BASE_URL + "/user-workflow-ids";
-export const WORKFLOW_OWNER_USER = WORKFLOW_BASE_URL + "/owner_user";
+export const WORKFLOW_OWNER_NAME = WORKFLOW_BASE_URL + "/owner_name";
export const WORKFLOW_NAME = WORKFLOW_BASE_URL + "/workflow_name";
export const WORKFLOW_PUBLIC_WORKFLOW = WORKFLOW_BASE_URL + "/publicised";
export const WORKFLOW_DESCRIPTION = WORKFLOW_BASE_URL +
"/workflow_description";
@@ -238,13 +238,12 @@ export class WorkflowPersistService {
}
/**
- * retrieve the complete information of the owner corresponding to the wid
- * can be used without logging in
- * @param wid
+ * Retrieve workflow owner name (no login required).
+ * @param wid workflow id
*/
- public getOwnerUser(wid: number): Observable<User> {
+ public getOwnerName(wid: number): Observable<string> {
const params = new HttpParams().set("wid", wid);
- return
this.http.get<User>(`${AppSettings.getApiEndpoint()}/${WORKFLOW_OWNER_USER}`, {
params });
+ return
this.http.get(`${AppSettings.getApiEndpoint()}/${WORKFLOW_OWNER_NAME}`, {
params, responseType: "text" });
}
/**
diff --git
a/frontend/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts
b/frontend/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts
index 2b6318fb53..3b0d0b8c50 100644
---
a/frontend/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts
+++
b/frontend/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts
@@ -98,10 +98,10 @@ export class HubWorkflowDetailComponent implements
AfterViewInit, OnDestroy, OnI
this.viewCount = count;
});
this.workflowPersistService
- .getOwnerUser(this.wid)
+ .getOwnerName(this.wid)
.pipe(untilDestroyed(this))
- .subscribe(owner => {
- this.ownerName = owner.name;
+ .subscribe(ownerName => {
+ this.ownerName = ownerName;
});
this.workflowPersistService
.getWorkflowName(this.wid)