Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ircb.storeclient import NetworkStore | ||
|
||
from .base import BasePublisher | ||
|
||
|
||
class NetworkPublisher(BasePublisher): | ||
|
||
name = 'networks' | ||
store = NetworkStore | ||
|
||
def __init__(self, user_id): | ||
super().__init__() | ||
self.user_id = user_id | ||
|
||
@property | ||
def id(self): | ||
return '{name}::{user_id}'.format( | ||
name=self.name, user_id=self.user_id) | ||
|
||
def fetch(self): | ||
results = yield from NetworkStore.get({ | ||
'query': { | ||
'user_id': self.user_id | ||
} | ||
}, raw=True) | ||
return results | ||
|
||
def skip_create(self, data): | ||
return self.skip_update(data) | ||
|
||
def skip_update(self, data): | ||
return data['user_id'] != self.user_id |