JujaLabs / juja-platform

0 stars 7 forks source link

Implement ARC-F4 feature (store messages with parsing by selected fields) #33

Open VadimDyachenko opened 6 years ago

VadimDyachenko commented 6 years ago

This feature stores messages by selected type. Before storing message it must be parsed into selected fields

petrokramar commented 6 years ago

1) What is this feature/fix provided for?

Convert raw messages to processed messages. Store converted messages.

2) List the objects you want to add or change, use appropriate API annotations

**Model**

    Add class

    public class Message {

    @Id
    @Field("_id")
    private String id;
    private String channel;
    private String text;
    private String team;
    private String type;
    private String user;
    private Date time;

**Repository**

    MessageRepository   

        Use mongoTemplate

        Collection name - raw_messages
        implement method List<RawMessage> getChannelRawMessages(String channelId, String ts)

        Collection name - messages
        implement method String ts getMaximumChannelMessageTs(String channelId)
        implement method void saveMessages(List<RawMessage> messages)

**Service**

    MessageService

        implement method void saveMessages()
        implement method String ts getMaximumChannelMessageTs(String channelId)
        implement method List<RawMessage> getChannelRawMessages(String channelId, String ts)
        implement method Message message convertRawMessageToMessage(RawMessage rawMessage)

    2.1 MessageService saveMessages()
        2.1.1.ChannelService List<Channel> getChannels()
        loop{
        2.1.2.MessageService String ts getMaximumChannelMessageTs(String channelId)
        2.1.3.MessageRepository List<RawMessage> getChannelRawMessages(String channelId, String ts)
        loop{
            2.1.4.MessageService Message message convertRawMessageToMessage(RawMessage rawMessage)
        }
        2.1.5.MessageRepository void saveMessages(List<Message> messages)
        }

**Controller**  

    No changes

3) Are there any special requirements or constraints?

MessageService method saveMessages() runs on schedule.

4) What behavior do you expect? Any examples?

Document example:

Collection - messages { "_id" : "1515767002.000721", "channel" : "C703E6B51", "type" : "message", "user" : "U707A97B6", "text" : "message text", "date" : ISODate("2018-01-12T14:23:22.721Z") }

hamster4n commented 6 years ago

1. What is this feature/fix provided for?

Convert raw messages to processed messages. Store converted messages.

2. List the objects you want to add or change, use appropriate API annotations

Model Add class Message { @Id @Field("_id") private String id; private String channel; private String text; private String team; private String type; private String user; private Date time;

Repository

MessageRepository

Use mongoTemplate

Collection name - raw_messages
implement method  **List<RawMessage> getChannelRawMessages(String channelId, String ts)**

Collection name - messages
implement method **String ts getMaximumChannelMessageTs(String channelId)**
implement method **void saveMessages(List<RawMessage> messages)**

Service

MessageService

implement method **void saveMessages()**
implement method **String ts getMaximumChannelMessageTs(String channelId)**
implement method **List<RawMessage> getChannelRawMessages(String channelId, String ts)**
implement method **Message message convertRawMessageToMessage(RawMessage rawMessage)**

2.1 MessageService saveMessages() 2.1.1.ChannelService List getChannels() loop{ 2.1.2.MessageService String ts getMaximumChannelMessageTs(String channelId) 2.1.3.MessageRepository List getChannelRawMessages(String channelId, String ts) loop{ 2.1.4.MessageService Message message convertRawMessageToMessage(RawMessage rawMessage) } 2.1.5.MessageRepository void saveMessages(List messages) } Controller

No changes

3. Are there any special requirements or constraints?

MessageService method saveMessages() runs on schedule.

4. What behavior do you expect? Any examples?

Document example:

Collection - messages { "_id" : "1515767002.000721", "channel" : "C703E6B51", "type" : "message", "user" : "U707A97B6", "text" : "message text", "date" : ISODate("2018-01-12T14:23:22.721Z") }