JujaLabs / juja-platform

0 stars 7 forks source link

Store raw json slack channels into database #78

Open petrokramar opened 6 years ago

petrokramar commented 6 years ago

1) What is this feature/fix provided for?

Import raw channels list from slack

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

**Model**

    Add class

    @Document
    public class RawChannel {
        private Map<String, Object> channelData;

**Repository**

    SlackRepository 

        Use restTemplate

        implement method List<RawChannel> getSlackChannels()
            URL - https://slack.com/api/channels.list       

    ChannelsRepository  

        Use mongoTemplate
        Collection name - raw_channels

        implement method void saveRawChannels(List<RawChannel> rawChannels)

**Service**

    SlackService

        implement method List<RawChannel> getSlackChannels()

    ChannelsService 

        implement method void saveRawChannels(List<RawChannel> rawChannels)

        where rawChannels are received from SlackService.getRawChannels().
        You need add pair key-value ("date" - current date) to the field channelData 
        of each rawChannel before saving document to collection "raw_channels". 

**Controller**  

    No changes

3) Are there any special requirements or constraints?

SlackChatService method saveRawChannels runs on schedule.

4) What behavior do you expect? Any examples?

Document example:

{ "_id" : ObjectId("5a64ebe1d3a73015f8ed6189"), "_class" : "com.example.demo.RawChannel", "channel" : { "id" : "C703E6B51", "name" : "general", "is_channel" : true, "created" : 1504873648, "is_archived" : false, "is_general" : true, "unlinked" : 0, "creator" : "U707A97B6", "name_normalized" : "general", "is_shared" : false, "is_org_shared" : false, "is_member" : true, "is_private" : false, "is_mpim" : false, "members" : [ "U707A97B6", "U712G0NUE" ], "topic" : { "value" : "Company-wide announcements and work-based matters", "creator" : "U707A97B6", "last_set" : 1504873648 }, "purpose" : { "value" : "This channel is for workspace-wide communication and announcements. All members are in this channel.", "creator" : "U707A97B6", "last_set" : 1504873648 }, "previous_names" : [], "num_members" : 2, "date" : ISODate("2018-01-21T19:37:05.758Z") } }

, where "date" is date of loading channels list from slack

hamster4n commented 6 years ago

1. What is this feature/fix provided for?

Import raw channels list from slack

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

Model

add class RawChannel whith field private Map<String,Object> channelData;

Repository

add class SlackRepository which use restTemplate and ipmlement method List getSlackChannels() URL - https://slack.com/api/channels.list

add class ChannelsRepository Use mongoTemplate Collection name - raw_channels implement method void saveRawChannels(List rawChannels)

Service

add class SlackService which implement method List getSlackChannels()

add class ChannelsService which implement method void saveRawChannels(List rawChannels)

where rawChannels are received from SlackService.getRawChannels(). You need add pair key-value ("date" - current date) to the field channelData of each rawChannel before saving document to collection "raw_channels".

Controller

no changes

3. Are there any special requirements or constraints?

SlackChatService method saveRawChannels runs on schedule.

4. What behavior do you expect? Any examples?

Document example:

{ "_id" : ObjectId("5a64ebe1d3a73015f8ed6189"), "_class" : "com.example.demo.RawChannel", "channel" : { "id" : "C703E6B51", "name" : "general", "is_channel" : true, "created" : 1504873648, "is_archived" : false, "is_general" : true, "unlinked" : 0, "creator" : "U707A97B6", "name_normalized" : "general", "is_shared" : false, "is_org_shared" : false, "is_member" : true, "is_private" : false, "is_mpim" : false, "members" : [ "U707A97B6", "U712G0NUE" ], "topic" : { "value" : "Company-wide announcements and work-based matters", "creator" : "U707A97B6", "last_set" : 1504873648 }, "purpose" : { "value" : "This channel is for workspace-wide communication and announcements. All members are in this channel.", "creator" : "U707A97B6", "last_set" : 1504873648 }, "previous_names" : [], "num_members" : 2, "date" : ISODate("2018-01-21T19:37:05.758Z") } }

, where "date" is date of loading channels list from slack

petrokramar commented 6 years ago

1. What is this feature/fix provided for?

Import raw channels list from slack

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

Model

add class RawChannel whith field private Map<String,Object> channelData;

Repository

add class SlackRepository which use restTemplate and ipmlement method List getSlackChannels() URL - https://slack.com/api/channels.list

add class ChannelsRepository Use mongoTemplate Collection name - raw_channels implement method void saveRawChannels(List rawChannels)

Service

add class SlackService which implement method List getSlackChannels()

add class ChannelsService which implement method void saveRawChannels(List rawChannels)

where rawChannels are received from SlackService.getRawChannels(). You need add pair key-value ("date" - current date) to the field channelData of each rawChannel before saving document to collection "raw_channels".

Controller

no changes

3. Are there any special requirements or constraints?

SlackChatService method saveRawChannels runs on schedule.

4. What behavior do you expect? Any examples?

Document example:

{ "_id" : ObjectId("5a64ebe1d3a73015f8ed6189"), "_class" : "com.example.demo.RawChannel", "channel" : { "id" : "C703E6B51", "name" : "general", "is_channel" : true, "created" : 1504873648, "is_archived" : false, "is_general" : true, "unlinked" : 0, "creator" : "U707A97B6", "name_normalized" : "general", "is_shared" : false, "is_org_shared" : false, "is_member" : true, "is_private" : false, "is_mpim" : false, "members" : [ "U707A97B6", "U712G0NUE" ], "topic" : { "value" : "Company-wide announcements and work-based matters", "creator" : "U707A97B6", "last_set" : 1504873648 }, "purpose" : { "value" : "This channel is for workspace-wide communication and announcements. All members are in this channel.", "creator" : "U707A97B6", "last_set" : 1504873648 }, "previous_names" : [], "num_members" : 2 } }

I removed "data" from channel structure because we decided to store only last raw information about channel.