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)
|
ch.setFormatter(log_format)
|
||||||
log.addHandler(ch)
|
log.addHandler(ch)
|
||||||
|
|
||||||
|
if args.update_orders:
|
||||||
|
orders = Orders(config)
|
||||||
|
orders.fetch_orders()
|
||||||
|
orders.update_project_list()
|
||||||
|
|
||||||
projects = Projects(config, args)
|
projects = Projects(config, args)
|
||||||
|
|
||||||
docs = Docs(projects.projects, args=args)
|
docs = Docs(projects.projects, args=args)
|
||||||
@@ -242,11 +247,6 @@ if __name__ == '__main__':
|
|||||||
if args.metrics:
|
if args.metrics:
|
||||||
projects.build_metrics()
|
projects.build_metrics()
|
||||||
|
|
||||||
if args.update_orders:
|
|
||||||
orders = Orders(config)
|
|
||||||
orders.fetch_orders()
|
|
||||||
orders.update_project_list()
|
|
||||||
|
|
||||||
if args.update_caravel:
|
if args.update_caravel:
|
||||||
caravel.create_macro_config()
|
caravel.create_macro_config()
|
||||||
caravel.instantiate()
|
caravel.instantiate()
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import stripe, os
|
import stripe, os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import yaml
|
import yaml
|
||||||
|
import requests
|
||||||
|
import pytz
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class Orders():
|
class Orders():
|
||||||
@@ -12,8 +15,30 @@ class Orders():
|
|||||||
self.orders = []
|
self.orders = []
|
||||||
|
|
||||||
def fetch_orders(self):
|
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
|
start_id = None
|
||||||
after_open_date = True
|
after_open_date = True
|
||||||
|
orders = []
|
||||||
|
|
||||||
while after_open_date:
|
while after_open_date:
|
||||||
checkouts = stripe.checkout.Session.list(limit=10, starting_after=start_id)
|
checkouts = stripe.checkout.Session.list(limit=10, starting_after=start_id)
|
||||||
@@ -29,15 +54,15 @@ class Orders():
|
|||||||
order = {
|
order = {
|
||||||
'git_url' : git_url,
|
'git_url' : git_url,
|
||||||
'email' : checkout['customer_details']['email'],
|
'email' : checkout['customer_details']['email'],
|
||||||
|
'time' : datetime.fromtimestamp(checkout['created']).replace(tzinfo=pytz.UTC),
|
||||||
}
|
}
|
||||||
self.orders.append(order)
|
orders.append(order)
|
||||||
|
|
||||||
# pagination
|
# pagination
|
||||||
start_id = checkout['id']
|
start_id = checkout['id']
|
||||||
|
|
||||||
# put in date order
|
# put in date order
|
||||||
self.orders.reverse()
|
return orders
|
||||||
return self.orders
|
|
||||||
|
|
||||||
def update_project_list(self):
|
def update_project_list(self):
|
||||||
project_list = {}
|
project_list = {}
|
||||||
|
|||||||
+10
-10
@@ -3,15 +3,15 @@
|
|||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
1:
|
1:
|
||||||
url: https://github.com/WallieEverest/tt03
|
url: https://github.com/MichaelBell/tt03-hovalaag
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
2:
|
2:
|
||||||
url: https://github.com/icegoat9/tinytapeout03-7seglife
|
url: https://github.com/dgarrett/tt03-num-latch
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
3:
|
3:
|
||||||
url: https://github.com/meiniKi/tt03-another-piece-of-pi
|
url: https://github.com/KolosKoblasz/tt03-knight_rider
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
4:
|
4:
|
||||||
@@ -19,25 +19,25 @@
|
|||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
5:
|
5:
|
||||||
url: https://github.com/KolosKoblasz/tt03-knight_rider
|
url: https://github.com/meiniKi/tt03-another-piece-of-pi
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
6:
|
6:
|
||||||
url: https://github.com/dgarrett/tt03-num-latch
|
url: https://github.com/icegoat9/tinytapeout03-7seglife
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
7:
|
7:
|
||||||
url: https://github.com/MichaelBell/tt03-hovalaag
|
url: https://github.com/WallieEverest/tt03
|
||||||
status: active
|
status: active
|
||||||
fill: false
|
fill: false
|
||||||
8:
|
8:
|
||||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
url: https://github.com/yannickreiss/TT3_Memory
|
||||||
status: active
|
status: active
|
||||||
fill: true
|
fill: false
|
||||||
9:
|
9:
|
||||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
url: https://github.com/yannickreiss/TT3_KS-Signal
|
||||||
status: active
|
status: active
|
||||||
fill: true
|
fill: false
|
||||||
10:
|
10:
|
||||||
url: https://github.com/TinyTapeout/tt03-test-invert
|
url: https://github.com/TinyTapeout/tt03-test-invert
|
||||||
status: active
|
status: active
|
||||||
|
|||||||
Reference in New Issue
Block a user