postgresql – Number of wise online users

I am not an expert in the database, but I try to make sure that the number of users online, indicated in time, is displayed in a graph. I managed to get the number of users online for the present time, but how to get a duration? I need every minute online user account.

here is my request up to now

select count (*) in connectivity_log cl inner join (
select cl2.socket_client_id, max (cl2.date_time) as MaxDate from
connectivity_log group cl2 by cl2.socket_client_client
) cl3 on cl.socket_client_id = cl3.socket_client_id and
cl3.MaxDate = cl.date_time and cl.connected = true

Here is the structure of my table

enter the description of the image here