after discussions

This commit is contained in:
cristi8
2021-06-17 17:52:18 +03:00
parent 16221cbd92
commit c5b86c4b40
3 changed files with 5 additions and 3 deletions
@@ -1,8 +1,7 @@
// /* istanbul ignore file */
exports.up = async ( knex ) => {
await knex.schema.createTable( 'stream_activity', table => {
// TODO: Question: delete the stream activity when deleting a stream?
table.string( 'streamId', 10 ).references( 'id' ).inTable( 'streams' ).onDelete( 'cascade' )
table.string( 'streamId', 10 )
table.timestamp( 'time' ).defaultTo( knex.fn.now( ) )
// No foreign keys because the referenced objects may be deleted, but we want to keep their ids here in this table for future analysis
table.string( 'resourceType' )
@@ -20,6 +20,9 @@ module.exports = {
await StreamActivity( ).insert( dbObject )
},
// get stream activity, user activity, user timeline
// paginate
// Only `streamId` is mandatory, the rest are optional filters
async getActivities( { streamId, timeStart, timeEnd, userId, actionType, resourceId } ) {
let dbQuery = StreamActivity().where( { streamId: streamId } )
@@ -90,7 +90,6 @@ module.exports = {
async streamCreate( parent, args, context, info ) {
let id = await createStream( { ...args.stream, ownerId: context.userId } )
// TODO: Question: Fetch user from db to include user name in activity log? (maybe useful if user deletes account)
await saveActivity( {
streamId: id,
resourceType: 'stream',
@@ -111,6 +110,7 @@ module.exports = {
await updateStream( update )
// TODO: Question: Fetch stream info from DB to include the old values in activity log? (we should have the old values in older entries in activity log)
// TODO: query old value and save it in `info` (new/old)
await saveActivity( {
streamId: args.stream.id,
resourceType: 'stream',