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

feat(logging): pass request logger to core/services/objects #2599

Merged
merged 22 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9750638
chore(logging): include additional detail on object upload logs
iainsproat Aug 7, 2024
03fd71c
allow max file size to be configurable
iainsproat Aug 7, 2024
20b7944
feat(logging): add logger to core/services/objects
iainsproat Aug 7, 2024
1de7f87
fix log line
iainsproat Aug 7, 2024
aa631e3
Merge branch 'main' into iain/logging-upload-objects
iainsproat Aug 7, 2024
f86f596
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 7, 2024
58c5814
fix tests
iainsproat Aug 7, 2024
591aac9
typo
iainsproat Aug 7, 2024
c4e7c60
fix variable name
iainsproat Aug 7, 2024
2133b5f
convert values to megabytes
iainsproat Aug 7, 2024
3a42e04
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 7, 2024
cfc42e7
calculating memory was causing the system to freeze
iainsproat Aug 7, 2024
c15ebec
calculating memory was causing the system to freeze
iainsproat Aug 8, 2024
4726620
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 8, 2024
15e8409
DRY the logging metadata
iainsproat Aug 8, 2024
12f86d4
Merge branch 'main' into iain/logging-upload-objects
iainsproat Aug 8, 2024
42061c7
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 8, 2024
353ffd7
all required variables should be passed to calculateLogMetadata
iainsproat Aug 8, 2024
aff35f2
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 8, 2024
e8e65dc
fix many things with the logging
iainsproat Aug 8, 2024
e877131
Merge branch 'iain/logging-upload-objects' into iain/pass-logger-to-o…
iainsproat Aug 8, 2024
43be2d5
Merge branch 'main' into iain/pass-logger-to-objects
iainsproat Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/fileimport-service/ifc/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = class ServerAPI {
obj.id = crypto.createHash('md5').update(JSON.stringify(obj)).digest('hex')
}

await this.createObject(this.streamId, obj)
await this.createObject({ streamId: this.streamId, object: obj })

return obj.id
}
Expand All @@ -40,7 +40,7 @@ module.exports = class ServerAPI {
return await this.createObjectsBatched(this.streamId, objs)
}

async createObject(streamId, object) {
async createObject({ streamId, object }) {
const insertionObject = this.prepInsertionObject(streamId, object)

const closures = []
Expand Down
4 changes: 2 additions & 2 deletions packages/server/modules/activitystream/tests/activity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Activity @activity', () => {
streamSecret.id = resStream1.body.data.streamCreate

// create commit (cr2)
testObj2.id = await createObject(streamSecret.id, testObj2)
testObj2.id = await createObject({ streamId: streamSecret.id, object: testObj2 })
const resCommit1 = await sendRequest(userCr.token, {
query: `mutation { commitCreate(commit: {streamId: "${streamSecret.id}", branchName: "main", objectId: "${testObj2.id}", message: "first commit"})}`
})
Expand All @@ -152,7 +152,7 @@ describe('Activity @activity', () => {
branchPublic.id = resBranch.body.data.branchCreate

// create commit #2 (iz3)
testObj.id = await createObject(streamPublic.id, testObj)
testObj.id = await createObject({ streamId: streamPublic.id, object: testObj })
const resCommit2 = await sendRequest(userIz.token, {
query: `mutation { commitCreate(commit: { streamId: "${streamPublic.id}", branchName: "${branchPublic.name}", objectId: "${testObj.id}", message: "first commit" })}`
})
Expand Down
34 changes: 23 additions & 11 deletions packages/server/modules/comments/tests/comments.graph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const queryComments = async ({ apollo, resources, shouldSucceed }) => {
bar: crs({ length: 5 })
}

const objectId = await createObject(resources.streamId, object)
const objectId = await createObject({ streamId: resources.streamId, object })

const numberOfComments = 3
const commentIds = await Promise.all(
Expand Down Expand Up @@ -361,9 +361,12 @@ const queryStreamCommentCount = async ({ apollo, resources, shouldSucceed }) =>
}

const queryObjectCommentCount = async ({ apollo, resources, shouldSucceed }) => {
const objectId = await createObject(resources.streamId, {
foo: 'bar',
noise: crs({ length: 5 })
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
noise: crs({ length: 5 })
}
})
await createComment({
userId: resources.testActorId,
Expand Down Expand Up @@ -394,9 +397,12 @@ const queryObjectCommentCount = async ({ apollo, resources, shouldSucceed }) =>
}

const queryCommitCommentCount = async ({ apollo, resources, shouldSucceed }) => {
const objectId = await createObject(resources.streamId, {
foo: 'bar',
notSignal: crs({ length: 10 })
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
notSignal: crs({ length: 10 })
}
})
const commitId = await createCommitByBranchName({
streamId: resources.streamId,
Expand Down Expand Up @@ -438,9 +444,12 @@ const queryCommitCollectionCommentCount = async ({
resources,
shouldSucceed
}) => {
const objectId = await createObject(resources.streamId, {
foo: 'bar',
almostMakesSense: crs({ length: 10 })
const objectId = await createObject({
streamId: resources.streamId,
object: {
foo: 'bar',
almostMakesSense: crs({ length: 10 })
}
})
const commitId = await createCommitByBranchName({
streamId: resources.streamId,
Expand Down Expand Up @@ -843,7 +852,10 @@ describe('Graphql @comments', () => {
})
}

const objectId = await createObject(stream.id, { test: 'object' })
const objectId = await createObject({
streamId: stream.id,
object: { test: 'object' }
})

const { id: commentId } = await createComment({
userId: myTestActor.id,
Expand Down
55 changes: 38 additions & 17 deletions packages/server/modules/comments/tests/comments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ describe('Comments @comments', () => {

stream.id = await createStream({ ...stream, ownerId: user.id })

testObject1.id = await createObject(stream.id, testObject1)
testObject2.id = await createObject(stream.id, testObject2)
testObject1.id = await createObject({ streamId: stream.id, object: testObject1 })
testObject2.id = await createObject({ streamId: stream.id, object: testObject2 })

commitId1 = await createCommitByBranchName({
streamId: stream.id,
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Comments @comments', () => {
const streamA = { name: 'Stream A' }
streamA.id = await createStream({ ...streamA, ownerId: user.id })
const objA = { foo: 'bar' }
objA.id = await createObject(streamA.id, objA)
objA.id = await createObject({ streamId: streamA.id, object: objA })
const commA = {}
commA.id = await createCommitByBranchName({
streamId: streamA.id,
Expand All @@ -177,7 +177,7 @@ describe('Comments @comments', () => {
const streamB = { name: 'Stream B' }
streamB.id = await createStream({ ...streamB, ownerId: otherUser.id })
const objB = { qux: 'mux' }
objB.id = await createObject(streamB.id, objB)
objB.id = await createObject({ streamId: streamB.id, object: objB })
const commB = {}
commB.id = await createCommitByBranchName({
streamId: streamB.id,
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('Comments @comments', () => {
const stream = { name: 'Bean Counter' }
stream.id = await createStream({ ...stream, ownerId: user.id })
const obj = { foo: 'bar' }
obj.id = await createObject(stream.id, obj)
obj.id = await createObject({ streamId: stream.id, object: obj })
const commit = {}
commit.id = await createCommitByBranchName({
streamId: stream.id,
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Comments @comments', () => {
const streamOther = { name: 'Bean Counter' }
streamOther.id = await createStream({ ...streamOther, ownerId: user.id })
const objOther = { 'are you bored': 'yes' }
objOther.id = await createObject(streamOther.id, objOther)
objOther.id = await createObject({ streamId: streamOther.id, object: objOther })
const commitOther = {}
commitOther.id = await createCommitByBranchName({
streamId: streamOther.id,
Expand Down Expand Up @@ -560,7 +560,10 @@ describe('Comments @comments', () => {
})

it('Should not return the same comment multiple times for multi resource comments', async () => {
const localObjectId = await createObject(stream.id, { testObject: 1 })
const localObjectId = await createObject({
streamId: stream.id,
object: { testObject: 1 }
})

const commentCount = 3
for (let i = 0; i < commentCount; i++) {
Expand Down Expand Up @@ -600,8 +603,11 @@ describe('Comments @comments', () => {
})

it('Should handle cursor and limit for queries', async () => {
const localObjectId = await createObject(stream.id, {
testObject: 'something completely different'
const localObjectId = await createObject({
streamId: stream.id,
object: {
testObject: 'something completely different'
}
})

const createdComments = []
Expand Down Expand Up @@ -691,7 +697,10 @@ describe('Comments @comments', () => {
})

it('Should return all the referenced resources for a comment', async () => {
const localObjectId = await createObject(stream.id, { anotherTestObject: 1 })
const localObjectId = await createObject({
streamId: stream.id,
object: { anotherTestObject: 1 }
})
const inputResources = [
{ resourceId: stream.id, resourceType: 'stream' },
{ resourceId: commitId1, resourceType: 'commit' },
Expand Down Expand Up @@ -722,7 +731,10 @@ describe('Comments @comments', () => {
})

it('Should return the same data when querying a single comment vs a list of comments', async () => {
const localObjectId = await createObject(stream.id, { anotherTestObject: 42 })
const localObjectId = await createObject({
streamId: stream.id,
object: { anotherTestObject: 42 }
})
await createComment({
userId: user.id,
input: {
Expand Down Expand Up @@ -753,8 +765,11 @@ describe('Comments @comments', () => {
})

it('Should be able to edit a comment text', async () => {
const localObjectId = await createObject(stream.id, {
anotherTestObject: crs({ length: 10 })
const localObjectId = await createObject({
streamId: stream.id,
object: {
anotherTestObject: crs({ length: 10 })
}
})
const { id: commentId } = await createComment({
userId: user.id,
Expand Down Expand Up @@ -789,8 +804,11 @@ describe('Comments @comments', () => {
})

it('Should not be allowed to edit a comment of another user if its restricted', async () => {
const localObjectId = await createObject(stream.id, {
anotherTestObject: crs({ length: 10 })
const localObjectId = await createObject({
streamId: stream.id,
object: {
anotherTestObject: crs({ length: 10 })
}
})
const { id: commentId } = await createComment({
userId: user.id,
Expand Down Expand Up @@ -908,8 +926,11 @@ describe('Comments @comments', () => {
})

it('Should not query archived comments unless asked', async () => {
const localObjectId = await createObject(stream.id, {
testObject: crs({ length: 10 })
const localObjectId = await createObject({
streamId: stream.id,
object: {
testObject: crs({ length: 10 })
}
})

const commentCount = 15
Expand Down
8 changes: 4 additions & 4 deletions packages/server/modules/core/graph/resolvers/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export = {
context.resourceAccessRules
)

const ids = await createObjects(
args.objectInput.streamId,
args.objectInput.objects
)
const ids = await createObjects({
streamId: args.objectInput.streamId,
objects: args.objectInput.objects
})
return ids
}
}
Expand Down
Loading