Refactor code, add more filtering

This commit is contained in:
Jesse Wierzbinski 2023-09-17 19:38:08 -10:00
parent 768d1858dc
commit 4d0283caf0
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
8 changed files with 397 additions and 151 deletions

View file

@ -19,6 +19,8 @@ beforeAll(async () => {
user.display_name = "";
user.bio = "";
await user.generateKeys();
await user.save();
});
@ -55,13 +57,9 @@ describe("POST /@test/inbox", () => {
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe("application/json");
const activity = await RawActivity.createQueryBuilder("activity")
// id is part of the jsonb column 'data'
.where("activity.data->>'id' = :id", {
id: "https://example.com/notes/1/activity",
})
.leftJoinAndSelect("activity.objects", "objects")
.getOne();
const activity = await RawActivity.getLatestById(
"https://example.com/notes/1/activity"
);
expect(activity).not.toBeUndefined();
expect(activity?.data).toEqual({
@ -118,15 +116,9 @@ describe("POST /@test/inbox", () => {
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe("application/json");
const activity = await RawActivity.createQueryBuilder("activity")
// Where id is part of the jsonb column 'data'
.where("activity.data->>'id' = :id", {
id: "https://example.com/notes/1/activity",
})
.leftJoinAndSelect("activity.objects", "objects")
// Sort by most recent
.orderBy("activity.data->>'published'", "DESC")
.getOne();
const activity = await RawActivity.getLatestById(
"https://example.com/notes/1/activity"
);
expect(activity).not.toBeUndefined();
expect(activity?.data).toEqual({
@ -183,15 +175,9 @@ describe("POST /@test/inbox", () => {
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toBe("application/json");
const activity = await RawActivity.createQueryBuilder("activity")
// Where id is part of the jsonb column 'data'
.where("activity.data->>'id' = :id", {
id: "https://example.com/notes/1/activity",
})
.leftJoinAndSelect("activity.objects", "objects")
// Sort by most recent
.orderBy("activity.data->>'published'", "DESC")
.getOne();
const activity = await RawActivity.getLatestById(
"https://example.com/notes/1/activity"
);
expect(activity).not.toBeUndefined();
expect(activity?.data).toEqual({

View file

@ -23,6 +23,8 @@ beforeAll(async () => {
user.display_name = "";
user.bio = "";
await user.generateKeys();
await user.save();
});