def get_users_emails(send_type):
 sql = "\n    SELECT json_build_object(\n            'user_id', osf_guid._id,\n            'info', json_agg(\n                json_build_object(\n                    'message', nd.message,\n                    'node_lineage', nd.node_lineage,\n                    '_id', nd._id\n                )\n            )\n        )\n    FROM osf_notificationdigest AS nd\n      LEFT JOIN osf_guid ON nd.user_id = osf_guid.object_id\n    WHERE send_type = %s\n    AND osf_guid.content_type_id = (SELECT id FROM django_content_type WHERE model = 'osfuser')\n    GROUP BY osf_guid.id\n    ORDER BY osf_guid.id ASC\n    "
 with connection.cursor() as cursor:
  cursor.execute(sql, [send_type])
  rows = list(sum(cursor.fetchall(), ()))
  if (len(rows) > 0):
   return rows
  else:
   return []

def get_users_emails ( send_type ) : sql = "\n    SELECT json_build_object(\n            'user_id', osf_guid._id,\n            'info', json_agg(\n                json_build_object(\n                    'message', nd.message,\n                    'node_lineage', nd.node_lineage,\n                    '_id', nd._id\n                )\n            )\n        )\n    FROM osf_notificationdigest AS nd\n      LEFT JOIN osf_guid ON nd.user_id = osf_guid.object_id\n    WHERE send_type = %s\n    AND osf_guid.content_type_id = (SELECT id FROM django_content_type WHERE model = 'osfuser')\n    GROUP BY osf_guid.id\n    ORDER BY osf_guid.id ASC\n    " with connection . cursor ( ) as cursor : cursor . execute ( sql , [ send_type ] ) rows = list ( sum ( cursor . fetchall ( ) , ( ) ) ) if ( len ( rows ) > 0 ) : return rows else : return [ ]
get all emails that need to be sent .