Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Criação do método Marreta.update_collection

  • Loading branch information...
commit 1cfd1fa06fa089486a5cc9dcb3a2a7c175244585 1 parent c8e94b3
@gustavofonseca authored
View
11 opac/utils/functions.py
@@ -72,11 +72,16 @@ def _what_have_changed(since=0, managerapi_dep=datacollector.SciELOManagerAPI):
data = scielo_api.get_changes(since=since)
- changed = identify_changes(data, full_collections, journals_a_la_carte)
+ changes_list = datacollector.ChangesList(data)
+ changes = changes_list.filter(collections=full_collections,
+ journals=journals_a_la_carte)
+
+ journals = [ch.resource_id for ch in changes.show('journals', unique=True)]
+ # issues = changes.show('issues', unique=True)
return {
- 'issues': scielo_api.get_issues(*changed['issues']),
- 'journals': scielo_api.get_journals(*changed['journals'])
+ 'journals': scielo_api.get_journals(*journals),
+ # 'issues': changes.show('issues', unique=True),
}
View
2  opac/utils/sync/datacollector.py
@@ -156,7 +156,7 @@ def _list_issues_uri(journal_meta, journal_dep=mongomodels.Journal):
journal_data = journal_dep.objects.find_one({'id': journal_meta.resource_id})
if not journal_data:
- raise ValueError('invalid id for Journals: %s' % journal_meta.resource_id)
+ return []
journal_doc = journal_dep(**journal_data)
View
8 opac/utils/sync/dataloader.py
@@ -38,3 +38,11 @@ def rebuild_collection(self, collection, new_data):
col.insert(data, w=1)
return None
+
+ def update_collection(self, collection, new_data):
+ col = self._mongoconn.db[collection]
+
+ for data in new_data:
+ col.update({'id': data['id']}, data, w=1, upsert=True)
+
+ return None
Please sign in to comment.
Something went wrong with that request. Please try again.