瀏覽代碼

implemented to_date file indexing

Gamaliel Espinoza 8 年之前
父節點
當前提交
a82420115e
共有 3 個文件被更改,包括 17 次插入7 次删除
  1. 1 1
      tools/fourier/__init__.py
  2. 15 5
      tools/fourier/cli.py
  3. 1 1
      tools/fourier/migrations.py

+ 1 - 1
tools/fourier/__init__.py

@@ -1 +1 @@
-__version__ = '1.0.6'
+__version__ = '1.0.7'

+ 15 - 5
tools/fourier/cli.py

@@ -58,9 +58,14 @@ def main():
     
     
     dbparser = subparsers.add_parser('db')
     dbparser = subparsers.add_parser('db')
     dbparser.add_argument('action')
     dbparser.add_argument('action')
-    dbparser.add_argument('-from-date', dest='from_date',
-                                        type=simple_date,
-                                        )
+    dbparser.add_argument('-from-date',
+                          dest='from_date',
+                          type=simple_date,
+                          )
+    dbparser.add_argument('-to-date',
+                          dest='to_date',
+                          type=simple_date,
+                          )
     dbparser.add_argument('-station', dest='station')
     dbparser.add_argument('-station', dest='station')
     dbparser.add_argument('--dry-run', dest='dry_run',
     dbparser.add_argument('--dry-run', dest='dry_run',
                           action='store_const',
                           action='store_const',
@@ -119,8 +124,13 @@ def main():
                         '%Y-%m-%dT%H-%M-%S'
                         '%Y-%m-%dT%H-%M-%S'
                     )
                     )
                     try:
                     try:
-                        if args.from_date:
-                            do_insert = dt >= args.from_date  
+                        if args.from_date and args.to_date:
+                            do_insert = dt >= args.from_date\
+                                    and dt <= args.to_date
+                        elif args.from_date:
+                            do_insert = dt >= args.from_date
+                        elif args.to_date:
+                            do_insert = dt <= args.to_date
                         else:
                         else:
                             do_insert = True
                             do_insert = True
 
 

+ 1 - 1
tools/fourier/migrations.py

@@ -5,6 +5,6 @@ versions = [
             "create table config(name text primary key, value text)",
             "create table config(name text primary key, value text)",
             "insert into config (name, value) values ('version', '1')",
             "insert into config (name, value) values ('version', '1')",
             'create table "station"(remote_id text, indice int, status int)'
             'create table "station"(remote_id text, indice int, status int)'
-        ],
+        ]
     ),
     ),
 ]
 ]