1
0
mirror of https://github.com/bspeice/metrik synced 2024-11-23 07:38:09 -05:00

Add a 'now' tag to the database records

This commit is contained in:
Bradlee Speice 2016-08-16 15:38:37 -04:00
parent 36ddd5d323
commit cd7009729e
4 changed files with 17 additions and 3 deletions

View File

@ -24,5 +24,13 @@
</value> </value>
</option> </option>
</inspection_tool> </inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoredIdentifiers">
<list>
<option value="quote_plus" />
<option value="six.moves.urllib.parse" />
</list>
</option>
</inspection_tool>
</profile> </profile>
</component> </component>

View File

@ -38,6 +38,12 @@
<property name="caretWidth" class="java.lang.Integer" /> <property name="caretWidth" class="java.lang.Integer" />
</properties> </properties>
</component> </component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="FrameworkDetectionExcludesConfiguration">
<type id="django" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> <component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" /> <OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" /> <OptionsSetting value="true" id="Remove" />

View File

@ -1,6 +1,7 @@
from luigi import Target from luigi import Target
from pymongo import MongoClient from pymongo import MongoClient
from metrik.conf import MONGO_HOST, MONGO_PORT, MONGO_DATABASE from metrik.conf import MONGO_HOST, MONGO_PORT, MONGO_DATABASE
from datetime import datetime
class MongoTarget(Target): class MongoTarget(Target):
@ -18,6 +19,7 @@ class MongoTarget(Target):
def persist(self, dict_object): def persist(self, dict_object):
id_dict = dict_object id_dict = dict_object
id_dict['_id'] = self.id id_dict['_id'] = self.id
id_dict['_retrieved'] = datetime.now()
return self.collection.insert_one(id_dict).inserted_id return self.collection.insert_one(id_dict).inserted_id
def retrieve(self): def retrieve(self):

View File

@ -1,14 +1,12 @@
from __future__ import print_function from __future__ import print_function
import csv import csv
import pytz
import requests import requests
from collections import namedtuple from collections import namedtuple
from dateutil.parser import parse from dateutil.parser import parse
from io import StringIO from io import StringIO
import logging
from luigi.parameter import DateParameter, Parameter from luigi.parameter import DateParameter, Parameter
# noinspection PyUnresolvedReferences
from six.moves.urllib.parse import quote_plus from six.moves.urllib.parse import quote_plus
from metrik.tasks.base import MongoCreateTask from metrik.tasks.base import MongoCreateTask