mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
support adding extra orders
This commit is contained in:
+6
-1
@@ -219,6 +219,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument('--dump-pdf', help="create pdf from the markdown")
|
parser.add_argument('--dump-pdf', help="create pdf from the markdown")
|
||||||
parser.add_argument('--build-hugo-content', help="directory to where to build hugo content")
|
parser.add_argument('--build-hugo-content', help="directory to where to build hugo content")
|
||||||
parser.add_argument('--metrics', help="print some project metrics", action="store_const", const=True)
|
parser.add_argument('--metrics', help="print some project metrics", action="store_const", const=True)
|
||||||
|
parser.add_argument('--add-extra-project', help="specify a github url to add. Project is added to the extra_projects list specifed in config.yaml")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -235,11 +236,15 @@ if __name__ == '__main__':
|
|||||||
ch.setFormatter(log_format)
|
ch.setFormatter(log_format)
|
||||||
log.addHandler(ch)
|
log.addHandler(ch)
|
||||||
|
|
||||||
if args.update_orders:
|
|
||||||
orders = Orders(config)
|
orders = Orders(config)
|
||||||
|
|
||||||
|
if args.update_orders:
|
||||||
orders.fetch_orders()
|
orders.fetch_orders()
|
||||||
orders.update_project_list()
|
orders.update_project_list()
|
||||||
|
|
||||||
|
if args.add_extra_project:
|
||||||
|
orders.add_extra_project(args.add_extra_project)
|
||||||
|
|
||||||
projects = Projects(config, args)
|
projects = Projects(config, args)
|
||||||
|
|
||||||
docs = Docs(projects.projects, args=args)
|
docs = Docs(projects.projects, args=args)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import stripe, os
|
import stripe, os
|
||||||
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import yaml
|
import yaml
|
||||||
import requests
|
import requests
|
||||||
@@ -15,9 +16,32 @@ class Orders():
|
|||||||
self.orders = []
|
self.orders = []
|
||||||
|
|
||||||
def fetch_orders(self):
|
def fetch_orders(self):
|
||||||
orders = self.fetch_stripe_orders() + self.fetch_university_orders()
|
orders = self.fetch_stripe_orders() + self.fetch_university_orders() + self.fetch_extra_orders()
|
||||||
self.orders = sorted(orders, key=lambda d: d['time'])
|
self.orders = sorted(orders, key=lambda d: d['time'])
|
||||||
|
|
||||||
|
def add_extra_project(self, git_url):
|
||||||
|
with open(self.config['extra_projects']) as fh:
|
||||||
|
config = yaml.safe_load(fh)
|
||||||
|
config.append({'project': {'url' : git_url, 'timestamp' : time.time()}})
|
||||||
|
with open(self.config['extra_projects'], 'w') as fh:
|
||||||
|
yaml.safe_dump(config, fh)
|
||||||
|
logging.info(f"added {git_url} to {self.config['extra_projects']}")
|
||||||
|
|
||||||
|
def fetch_extra_orders(self):
|
||||||
|
with open(self.config['extra_projects']) as fh:
|
||||||
|
config = yaml.safe_load(fh)
|
||||||
|
|
||||||
|
orders = []
|
||||||
|
for project in config:
|
||||||
|
orders.append({
|
||||||
|
'git_url' : project['project']['url'],
|
||||||
|
'email' : None,
|
||||||
|
'time' : datetime.fromtimestamp(project['project']['timestamp']).replace(tzinfo=pytz.UTC)
|
||||||
|
})
|
||||||
|
|
||||||
|
logging.info(f"fetched extra {len(orders)} orders")
|
||||||
|
return orders
|
||||||
|
|
||||||
def fetch_university_orders(self):
|
def fetch_university_orders(self):
|
||||||
name = self.config['name']
|
name = self.config['name']
|
||||||
url = f'https://app.tinytapeout.com/api/submissions?shuttle={name}'
|
url = f'https://app.tinytapeout.com/api/submissions?shuttle={name}'
|
||||||
|
|||||||
Reference in New Issue
Block a user