JujaLabs / juja-platform

0 stars 7 forks source link

Implement ARC-F3 feature (store raw json slack messages into database) #32

Open VadimDyachenko opened 6 years ago

VadimDyachenko commented 6 years ago

This feature must be receive messages from slack and stores into database all messages without any parsing.

petrokramar commented 6 years ago

1) What is this feature/fix provided for?

Import raw messages from slack

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

**Model**

    Add class

    @Document
    public class RawMessage {
    @Id
    @Field("_id")
    private String id;
    private Map<String, Object> channelData;
    private String channel;
    private Date date;

**Repository**

    SlackRepository 

        Use restTemplate
        URL - https://slack.com/api/conversations.history
        Method - GET    
        implement method void SlackRepository List<RawMessage> getRawMessages(String channelId, String ts)

    ChannelRepository   

        Use mongoTemplate
        Collection name - channels

        implement method List<Channel> getChannels()
        implement method void saveChannel(Channel channel)  

        Collection name - raw_messages

        implement method void saveRawMessages(List<RawMessage> messages)

**Service**

    SlackService

        SlackService List<RawMessage> getRawMessages(String channelId, String ts)

    ChannelService  

        implement method List<Channel> getChannels()
        implement method void saveChannel(Channel channel)  

    MessageService

        implement method void saveRawMessages(),

    2.1 MessageService saveRawMessages()
        2.1.1.ChannelService List<Channel> getChannels()
        loop{
        2.1.2.SlackService List<RawMessage> getRawMessages(String channelId, String ts),
            where ts is channel.ts.
            2.1.2.1.SlackRepository List<RawMessage> getRawMessages(String channelId, String ts)
        2.1.3.MessageRepository void saveRawMessages(List<RawMessage> messages)
        2.1.4.ChannelsRepository void saveChannel(Channel channel) (Store max ts of current channel)    
        }
**Controller**  

    No changes

3) Are there any special requirements or constraints?

MessageService method saveRawMessages runs on schedule.

4) What behavior do you expect? Any examples?

Document example (document structure depend on type of message):

Collection - raw_messages { "_id" : "1515767002.000721", "type" : "message", "user" : "U707A97B6", "text" : "120118 1623 2", "ts" : "1515767002.000721", "channel" : "C703E6B51", "date" : ISODate("2018-01-12T14:23:22.721Z") } _id, channel and date must be inserted into message before store it in database.
You need refresh ts in current channel after recording all channel's messages.

hamster4n commented 6 years ago

1. What is this feature/fix provided for?

Import raw messages from slack

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

Model

Add class RawMessage { @Id @Field("_id") private String id; private Map<String, Object> channelData; private String channel; private Date date;

Repository

SlackRepository
Use restTemplate URL - https://slack.com/api/conversations.history Method - GET
implement method void SlackRepository List getRawMessages(String channelId, String ts)

ChannelRepository
Use mongoTemplate Collection name - channels

implement method **List<Channel> getChannels()**
implement method **void saveChannel(Channel channel)**  

Collection name - raw_messages

implement method **void saveRawMessages(List<RawMessage> messages)**

Service

SlackService

**SlackService List<RawMessage> getRawMessages(String channelId, String ts)**
    //not understad

ChannelService

implement method **List<Channel> getChannels()**
implement method **void saveChannel(Channel channel)**  

MessageService

implement method **void saveRawMessages()**

2.1 MessageService saveRawMessages()

2.1.1.ChannelService List<Channel> getChannels()
loop{
2.1.2.SlackService List<RawMessage> getRawMessages(String channelId, String ts),
    where ts is channel.ts.
    2.1.2.1.SlackRepository List<RawMessage> getRawMessages(String channelId, String ts)
2.1.3.MessageRepository void saveRawMessages(List<RawMessage> messages)
2.1.4.ChannelsRepository void saveChannel(Channel channel) (Store max ts of current channel)    
}

Controller

No changes

3. Are there any special requirements or constraints?

MessageService method saveRawMessages runs on schedule.

4. What behavior do you expect? Any examples?

Document example (document structure depend on type of message):

Collection - raw_messages { "_id" : "1515767002.000721", "type" : "message", "user" : "U707A97B6", "text" : "120118 1623 2", "ts" : "1515767002.000721", "channel" : "C703E6B51", "date" : ISODate("2018-01-12T14:23:22.721Z") } _id, channel and date must be inserted into message before store it in database. You need refresh ts in current channel after recording all channel's messages.