SELECT emails.id polymorphic_id, 'Emails' polymorphic_module FROM emails
								   JOIN emails_text on emails.id = emails_text.email_id
                                   WHERE (type = 'out' OR status = 'sent') AND assigned_user_id = '9c983e8e-5b2b-11e9-aa8e-069940e16132' AND emails.deleted = '0' AND status NOT IN ('archived') AND type NOT IN ('archived')