mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
handle uni orders
This commit is contained in:
+5
-5
@@ -231,6 +231,11 @@ if __name__ == '__main__':
|
||||
ch.setFormatter(log_format)
|
||||
log.addHandler(ch)
|
||||
|
||||
if args.update_orders:
|
||||
orders = Orders(config)
|
||||
orders.fetch_orders()
|
||||
orders.update_project_list()
|
||||
|
||||
projects = Projects(config, args)
|
||||
|
||||
docs = Docs(projects.projects, args=args)
|
||||
@@ -242,11 +247,6 @@ if __name__ == '__main__':
|
||||
if args.metrics:
|
||||
projects.build_metrics()
|
||||
|
||||
if args.update_orders:
|
||||
orders = Orders(config)
|
||||
orders.fetch_orders()
|
||||
orders.update_project_list()
|
||||
|
||||
if args.update_caravel:
|
||||
caravel.create_macro_config()
|
||||
caravel.instantiate()
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import stripe, os
|
||||
from datetime import datetime
|
||||
import yaml
|
||||
import requests
|
||||
import pytz
|
||||
import logging
|
||||
|
||||
|
||||
class Orders():
|
||||
@@ -12,8 +15,30 @@ class Orders():
|
||||
self.orders = []
|
||||
|
||||
def fetch_orders(self):
|
||||
orders = self.fetch_stripe_orders() + self.fetch_university_orders()
|
||||
self.orders = sorted(orders, key=lambda d: d['time'])
|
||||
|
||||
def fetch_university_orders(self):
|
||||
name = self.config['name']
|
||||
url = f'https://app.tinytapeout.com/api/submissions?shuttle={name}'
|
||||
r = requests.get(url)
|
||||
if r.status_code != 200:
|
||||
logging.warning("couldn't download {}".format(url))
|
||||
exit(1)
|
||||
|
||||
orders = []
|
||||
for item in r.json()['items']:
|
||||
orders.append({
|
||||
'git_url' : item['repo'],
|
||||
'email' : None,
|
||||
'time' : datetime.strptime(item['time'], '%Y-%m-%dT%H:%M:%S.%f%z').replace(tzinfo=pytz.UTC)
|
||||
})
|
||||
return orders
|
||||
|
||||
def fetch_stripe_orders(self):
|
||||
start_id = None
|
||||
after_open_date = True
|
||||
orders = []
|
||||
|
||||
while after_open_date:
|
||||
checkouts = stripe.checkout.Session.list(limit=10, starting_after=start_id)
|
||||
@@ -29,15 +54,15 @@ class Orders():
|
||||
order = {
|
||||
'git_url' : git_url,
|
||||
'email' : checkout['customer_details']['email'],
|
||||
'time' : datetime.fromtimestamp(checkout['created']).replace(tzinfo=pytz.UTC),
|
||||
}
|
||||
self.orders.append(order)
|
||||
orders.append(order)
|
||||
|
||||
# pagination
|
||||
start_id = checkout['id']
|
||||
|
||||
# put in date order
|
||||
self.orders.reverse()
|
||||
return self.orders
|
||||
return orders
|
||||
|
||||
def update_project_list(self):
|
||||
project_list = {}
|
||||
|
||||
+10
-10
@@ -3,15 +3,15 @@
|
||||
status: active
|
||||
fill: false
|
||||
1:
|
||||
url: https://github.com/WallieEverest/tt03
|
||||
url: https://github.com/MichaelBell/tt03-hovalaag
|
||||
status: active
|
||||
fill: false
|
||||
2:
|
||||
url: https://github.com/icegoat9/tinytapeout03-7seglife
|
||||
url: https://github.com/dgarrett/tt03-num-latch
|
||||
status: active
|
||||
fill: false
|
||||
3:
|
||||
url: https://github.com/meiniKi/tt03-another-piece-of-pi
|
||||
url: https://github.com/KolosKoblasz/tt03-knight_rider
|
||||
status: active
|
||||
fill: false
|
||||
4:
|
||||
@@ -19,25 +19,25 @@
|
||||
status: active
|
||||
fill: false
|
||||
5:
|
||||
url: https://github.com/KolosKoblasz/tt03-knight_rider
|
||||
url: https://github.com/meiniKi/tt03-another-piece-of-pi
|
||||
status: active
|
||||
fill: false
|
||||
6:
|
||||
url: https://github.com/dgarrett/tt03-num-latch
|
||||
url: https://github.com/icegoat9/tinytapeout03-7seglife
|
||||
status: active
|
||||
fill: false
|
||||
7:
|
||||
url: https://github.com/MichaelBell/tt03-hovalaag
|
||||
url: https://github.com/WallieEverest/tt03
|
||||
status: active
|
||||
fill: false
|
||||
8:
|
||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
||||
url: https://github.com/yannickreiss/TT3_Memory
|
||||
status: active
|
||||
fill: true
|
||||
fill: false
|
||||
9:
|
||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
||||
url: https://github.com/yannickreiss/TT3_KS-Signal
|
||||
status: active
|
||||
fill: true
|
||||
fill: false
|
||||
10:
|
||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
||||
status: active
|
||||
|
||||
Reference in New Issue
Block a user