Commit b4238b34 authored by lopze94's avatar lopze94
Browse files

Fixed all activity feed

parent ad611d3a
Pipeline #4233 failed with stage
in 2 minutes and 8 seconds
......@@ -36,7 +36,8 @@ router.get('/locations', handlers.get_locations = async (req, res, next)=>{
router.get('/activity', handlers.get_all_activity = async (req, res, next)=>{
const db = require('../../db/v1')
const activity = await db.activity.getForAll()
const user_uuid = req.user.uuid
const activity = await db.activity.getUserProjectsActivity(user_uuid)
if(!activity) return next();
return res.json(activity)
......
......@@ -48,9 +48,10 @@ activity.create = async ({type: activity_type, user: user_uuid, task: task_uuid,
return joinjs.map(result.rows, relationMaps, 'activityMap', 'activity_')[0]
}
activity.getForAll = async () => {
activity.getUserProjectsActivity = async (user_uuid) => {
const query = {
text: 'select * from get_all_activity()'
text: 'select * from get_activity_for_user_projects($1)',
values: [user_uuid]
}
debug(query)
......
......@@ -29,11 +29,14 @@ begin
return query select * from v_activity where activity_uuid = new_activity_uuid;
end $function$;
create or replace function public.get_all_activity()
create or replace function public.get_activity_for_user_projects(_user_uuid uuid)
returns setof public.v_activity
language plpgsql
as $function$ begin
return query select * from v_activity;
return query select v_activity.*
from v_project
left join v_activity on "v_activity".activity_project_uuid = "v_project".project_uuid
where member_uuid = _user_uuid;
end $function$;
create or replace function public.get_activity_for_user(_user_uuid uuid)
......@@ -55,4 +58,17 @@ create or replace function public.get_activity_for_project(_project_uuid uuid)
language plpgsql
as $function$ begin
return query select * from v_activity where activity_project_uuid = _project_uuid;
end $function$;
\ No newline at end of file
end $function$;
select distinct
project_uuid,
project_name,
member_uuid,
member_firstname,
member_lastname,
member_username
from v_project
left join v_activity on v_activity.project_uuid = v_project.project_uuid
where member_uuid = '3b662379-27cd-47e7-9f90-08655c508df5' and project_deleted = false
;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment