mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-22 07:58:06 +00:00
This commit is contained in:
parent
e33d64467a
commit
b45ed2c8de
@ -654,6 +654,7 @@ public interface CollectionDAO {
|
|||||||
+ "LIMIT :limit")
|
+ "LIMIT :limit")
|
||||||
List<String> listThreadsByFollowsBefore(
|
List<String> listThreadsByFollowsBefore(
|
||||||
@Bind("userId") String userId,
|
@Bind("userId") String userId,
|
||||||
|
@BindList("teamIds") List<String> teamIds,
|
||||||
@Bind("limit") int limit,
|
@Bind("limit") int limit,
|
||||||
@Bind("before") long before,
|
@Bind("before") long before,
|
||||||
@Bind("resolved") boolean resolved,
|
@Bind("resolved") boolean resolved,
|
||||||
@ -668,6 +669,7 @@ public interface CollectionDAO {
|
|||||||
+ "LIMIT :limit")
|
+ "LIMIT :limit")
|
||||||
List<String> listThreadsByFollowsAfter(
|
List<String> listThreadsByFollowsAfter(
|
||||||
@Bind("userId") String userId,
|
@Bind("userId") String userId,
|
||||||
|
@BindList("teamIds") List<String> teamIds,
|
||||||
@Bind("limit") int limit,
|
@Bind("limit") int limit,
|
||||||
@Bind("after") long after,
|
@Bind("after") long after,
|
||||||
@Bind("resolved") boolean resolved,
|
@Bind("resolved") boolean resolved,
|
||||||
@ -679,7 +681,10 @@ public interface CollectionDAO {
|
|||||||
+ "((fromEntity='user' AND fromId= :userId) OR "
|
+ "((fromEntity='user' AND fromId= :userId) OR "
|
||||||
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation= :relation)")
|
+ "(fromEntity='team' AND fromId IN (<teamIds>))) AND relation= :relation)")
|
||||||
int listCountThreadsByFollows(
|
int listCountThreadsByFollows(
|
||||||
@Bind("userId") String userId, @Bind("resolved") boolean resolved, @Bind("relation") int relation);
|
@Bind("userId") String userId,
|
||||||
|
@BindList("teamIds") List<String> teamIds,
|
||||||
|
@Bind("resolved") boolean resolved,
|
||||||
|
@Bind("relation") int relation);
|
||||||
|
|
||||||
@SqlQuery(
|
@SqlQuery(
|
||||||
"SELECT json FROM thread_entity WHERE updatedAt > :before AND resolved = :resolved AND id in ("
|
"SELECT json FROM thread_entity WHERE updatedAt > :before AND resolved = :resolved AND id in ("
|
||||||
|
@ -550,13 +550,19 @@ public class FeedRepository {
|
|||||||
private FilteredThreads getThreadsByFollows(
|
private FilteredThreads getThreadsByFollows(
|
||||||
String userId, int limit, long time, boolean isResolved, PaginationType paginationType) throws IOException {
|
String userId, int limit, long time, boolean isResolved, PaginationType paginationType) throws IOException {
|
||||||
List<String> jsons;
|
List<String> jsons;
|
||||||
|
List<String> teamIds = getTeamIds(userId);
|
||||||
if (paginationType == PaginationType.BEFORE) {
|
if (paginationType == PaginationType.BEFORE) {
|
||||||
jsons = dao.feedDAO().listThreadsByFollowsBefore(userId, limit, time, isResolved, Relationship.FOLLOWS.ordinal());
|
jsons =
|
||||||
|
dao.feedDAO()
|
||||||
|
.listThreadsByFollowsBefore(userId, teamIds, limit, time, isResolved, Relationship.FOLLOWS.ordinal());
|
||||||
} else {
|
} else {
|
||||||
jsons = dao.feedDAO().listThreadsByFollowsAfter(userId, limit, time, isResolved, Relationship.FOLLOWS.ordinal());
|
jsons =
|
||||||
|
dao.feedDAO()
|
||||||
|
.listThreadsByFollowsAfter(userId, teamIds, limit, time, isResolved, Relationship.FOLLOWS.ordinal());
|
||||||
}
|
}
|
||||||
List<Thread> threads = JsonUtils.readObjects(jsons, Thread.class);
|
List<Thread> threads = JsonUtils.readObjects(jsons, Thread.class);
|
||||||
int totalCount = dao.feedDAO().listCountThreadsByFollows(userId, isResolved, Relationship.FOLLOWS.ordinal());
|
int totalCount =
|
||||||
|
dao.feedDAO().listCountThreadsByFollows(userId, teamIds, isResolved, Relationship.FOLLOWS.ordinal());
|
||||||
return new FilteredThreads(threads, totalCount);
|
return new FilteredThreads(threads, totalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
package org.openmetadata.catalog.resources.feeds;
|
package org.openmetadata.catalog.resources.feeds;
|
||||||
|
|
||||||
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
||||||
|
import static javax.ws.rs.core.Response.Status.CREATED;
|
||||||
import static javax.ws.rs.core.Response.Status.FORBIDDEN;
|
import static javax.ws.rs.core.Response.Status.FORBIDDEN;
|
||||||
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -518,6 +519,31 @@ public class FeedResourceTest extends CatalogApplicationTest {
|
|||||||
assertEquals(2, threads.getPaging().getTotal());
|
assertEquals(2, threads.getPaging().getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void list_threadsWithFollowsFilter() throws HttpResponseException {
|
||||||
|
// Get the initial thread count of TABLE2
|
||||||
|
String entityLink = String.format("<#E/table/%s>", TABLE2.getFullyQualifiedName());
|
||||||
|
int initialThreadCount = listThreads(entityLink, null, AUTH_HEADERS).getPaging().getTotal();
|
||||||
|
|
||||||
|
// Create threads
|
||||||
|
createAndCheck(create().withMessage("Message 1").withAbout(entityLink), ADMIN_AUTH_HEADERS);
|
||||||
|
|
||||||
|
createAndCheck(create().withMessage("Message 2").withAbout(entityLink), ADMIN_AUTH_HEADERS);
|
||||||
|
|
||||||
|
// Make the USER follow TABLE2
|
||||||
|
followTable(TABLE2.getId(), USER.getId(), AUTH_HEADERS);
|
||||||
|
|
||||||
|
ThreadList threads = listThreadsWithFilter(USER.getId().toString(), FilterType.FOLLOWS.toString(), AUTH_HEADERS);
|
||||||
|
assertEquals(initialThreadCount + 2, threads.getPaging().getTotal());
|
||||||
|
assertEquals(initialThreadCount + 2, threads.getData().size());
|
||||||
|
assertEquals("Message 2", threads.getData().get(0).getMessage());
|
||||||
|
|
||||||
|
// Filter by follows for another user should return 0 threads
|
||||||
|
threads = listThreadsWithFilter(USER2.getId().toString(), FilterType.FOLLOWS.toString(), AUTH_HEADERS);
|
||||||
|
assertEquals(0, threads.getPaging().getTotal());
|
||||||
|
assertEquals(0, threads.getData().size());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void list_threadsWithInvalidFilter() {
|
void list_threadsWithInvalidFilter() {
|
||||||
assertResponse(
|
assertResponse(
|
||||||
@ -679,6 +705,12 @@ public class FeedResourceTest extends CatalogApplicationTest {
|
|||||||
return TestUtils.get(target, ThreadList.class, authHeaders);
|
return TestUtils.get(target, ThreadList.class, authHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void followTable(UUID tableId, UUID userId, Map<String, String> authHeaders)
|
||||||
|
throws HttpResponseException {
|
||||||
|
WebTarget target = getResource("tables/" + tableId + "/followers");
|
||||||
|
TestUtils.put(target, userId.toString(), CREATED, authHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
public static ThreadList listThreadsWithFilter(String userId, String filterType, Map<String, String> authHeaders)
|
public static ThreadList listThreadsWithFilter(String userId, String filterType, Map<String, String> authHeaders)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
WebTarget target = getResource("feed");
|
WebTarget target = getResource("feed");
|
||||||
|
@ -54,6 +54,7 @@ const jsonData = {
|
|||||||
'fetch-data-error': 'Error while fetching data!',
|
'fetch-data-error': 'Error while fetching data!',
|
||||||
'fetch-database-details-error': 'Error while fetching database details!',
|
'fetch-database-details-error': 'Error while fetching database details!',
|
||||||
'fetch-database-tables-error': 'Error while fetching database tables!',
|
'fetch-database-tables-error': 'Error while fetching database tables!',
|
||||||
|
'fetch-activity-feed-error': 'Error while fetching activity feeds!',
|
||||||
'fetch-entity-feed-error': 'Error while fetching entity feeds!',
|
'fetch-entity-feed-error': 'Error while fetching entity feeds!',
|
||||||
'fetch-entity-feed-count-error': 'Error while fetching entity feed count!',
|
'fetch-entity-feed-count-error': 'Error while fetching entity feed count!',
|
||||||
'fetch-entity-count-error': 'Error while fetching entity count!',
|
'fetch-entity-count-error': 'Error while fetching entity count!',
|
||||||
|
@ -238,11 +238,13 @@ const MyDataPage = () => {
|
|||||||
|
|
||||||
setEntityThread((prevData) => [...prevData, ...data]);
|
setEntityThread((prevData) => [...prevData, ...data]);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((err: AxiosError) => {
|
||||||
showToast({
|
handleShowErrorToast(
|
||||||
variant: 'error',
|
getErrorText(
|
||||||
body: 'Error while fetching the Activity Feed',
|
err,
|
||||||
});
|
jsonData['api-error-messages']['fetch-activity-feed-error']
|
||||||
|
)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsFeedLoading(false);
|
setIsFeedLoading(false);
|
||||||
|
@ -106,7 +106,17 @@ export const getErrorText = (
|
|||||||
value: AxiosError | string,
|
value: AxiosError | string,
|
||||||
fallbackText: string
|
fallbackText: string
|
||||||
): string => {
|
): string => {
|
||||||
return (
|
let errorText;
|
||||||
(isString(value) ? value : value.response?.data?.message) || fallbackText
|
if (isString(value)) {
|
||||||
);
|
return value;
|
||||||
|
} else {
|
||||||
|
errorText = value.response?.data?.message;
|
||||||
|
if (!errorText) {
|
||||||
|
// if error text is undefined or null or empty, try responseMessage in data
|
||||||
|
errorText = value.response?.data?.responseMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if error text is still empty, return the fallback text
|
||||||
|
return errorText || fallbackText;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user