File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
2
from ircb .publishers .logs import MessageLogPublisher
3
+ from ircb .publishers .networks import NetworkPublisher
3
4
4
5
if __name__ == '__main__' :
5
6
import asyncio
15
16
except :
16
17
print ("Usage: __init__.py '<hostname>' '<roomname>' '<user_id>'" )
17
18
sys .exit (1 )
18
- publisher = MessageLogPublisher (hostname , roomname , int (user_id ))
19
- publisher .run ()
19
+ message_log_pub = MessageLogPublisher (hostname , roomname , int (user_id ))
20
+ message_log_pub .run ()
21
+
22
+ network_pub = NetworkPublisher (int (user_id ))
23
+ network_pub .run ()
24
+
20
25
loop = asyncio .get_event_loop ()
21
26
loop .run_forever ()
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from ircb .storeclient import NetworkStore
4
+
5
+ from .base import BasePublisher
6
+
7
+
8
+ class NetworkPublisher (BasePublisher ):
9
+
10
+ name = 'networks'
11
+ store = NetworkStore
12
+
13
+ def __init__ (self , user_id ):
14
+ super ().__init__ ()
15
+ self .user_id = user_id
16
+
17
+ @property
18
+ def id (self ):
19
+ return '{name}::{user_id}' .format (
20
+ name = self .name , user_id = self .user_id )
21
+
22
+ def fetch (self ):
23
+ results = yield from NetworkStore .get ({
24
+ 'query' : {
25
+ 'user_id' : self .user_id
26
+ }
27
+ }, raw = True )
28
+ return results
29
+
30
+ def skip_create (self , data ):
31
+ return self .skip_update (data )
32
+
33
+ def skip_update (self , data ):
34
+ return data ['user_id' ] != self .user_id
You can’t perform that action at this time.
0 commit comments