Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Update database
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Bore committed Jun 20, 2019
1 parent e2a5d88 commit d43e20d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 23 deletions.
59 changes: 38 additions & 21 deletions oppdaterdatabase.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import json
import pandas as pd
import pyperclip
Expand Down Expand Up @@ -63,8 +64,7 @@ def save_database(database, path):

def get_input():
try:
untappdnummer = input(colored('Skriv inn untappd nummer: ', 'yellow'))
untappdnummer = int(untappdnummer)
untappdnummer = int(input(colored('Skriv inn untappd nummer: ', 'yellow')))
if not untappdnummer:
return 0

Expand All @@ -75,30 +75,47 @@ def get_input():

database = load_database()
databaseset = set(database.keys())
produktdata = load_products()
produktdata.sort_values(by='Varenummer', ascending=False, inplace=True)

print()

for index, row in produktdata.iterrows():
if str(row['Varenummer']) in databaseset:
continue
parser = argparse.ArgumentParser(description='Process some integers.')

print(f"Varenummer : {row['Varenummer']}")
print(f"Varenavn : {row['Varenavn']}")
print(f"Produsent : {row['Produsent']}")
print(f"Varetype : {row['Varetype']}")
print(f"Land : {row['Land']}")
print(f"Alkohol : {row['Alkohol']}")
parser.add_argument('--manual', dest='manual', action='store_true')
parser.set_defaults(manual=False)
args = parser.parse_args()

pyperclip.copy(row['Varenavn'])
if args.manual:
while True:
polnummer = int(input(colored('Skriv inn vinmonopol nummer: ', 'yellow')))
untappdnummer = int(input(colored('Skriv inn untappd nummer: ', 'yellow')))

varenummer = get_input()
if varenummer > 0:
database[str(row['Varenummer'])] = varenummer
database[str(polnummer)] = untappdnummer
save_database(database, databasePath)
print(colored('Saved', 'green'))
else:
print(colored('Skipped', 'red'))

print()
print()
else:
produktdata = load_products()
produktdata.sort_values(by='Varenummer', ascending=False, inplace=True)

for index, row in produktdata.iterrows():
if str(row['Varenummer']) in databaseset:
continue

print(f"Varenummer : {row['Varenummer']}")
print(f"Varenavn : {row['Varenavn']}")
print(f"Produsent : {row['Produsent']}")
print(f"Varetype : {row['Varetype']}")
print(f"Land : {row['Land']}")
print(f"Alkohol : {row['Alkohol']}")

pyperclip.copy(row['Varenavn'])

varenummer = get_input()
if varenummer > 0:
database[str(row['Varenummer'])] = varenummer
save_database(database, databasePath)
print(colored('Saved', 'green'))
else:
print(colored('Skipped', 'red'))

print()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tappdopolet",
"version": "1.1.3",
"version": "1.1.4",
"main": "index.js",
"scripts": {
"start": "webpack --mode development --watch",
Expand Down
57 changes: 57 additions & 0 deletions src/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"2021702": 487,
"2022001": 4168,
"2022002": 4168,
"2061102": 7768,
"2063002": 8021,
"2063302": 614300,
"2064001": 989248,
Expand Down Expand Up @@ -272,6 +273,9 @@
"5472802": 1671561,
"5472902": 1671548,
"5473002": 1595352,
"5474302": 155431,
"5474402": 142006,
"5474502": 85303,
"5479302": 1190874,
"5492702": 1327084,
"5522902": 19245,
Expand Down Expand Up @@ -376,6 +380,7 @@
"7321502": 1988631,
"7321602": 1987217,
"7322402": 1831681,
"7334402": 1501485,
"7335402": 660490,
"7343101": 1759611,
"7343402": 1924839,
Expand Down Expand Up @@ -407,6 +412,7 @@
"7397102": 838296,
"7397202": 731265,
"7397402": 724668,
"7430102": 6758,
"7430502": 394029,
"7431002": 19459,
"7431102": 1174004,
Expand Down Expand Up @@ -700,6 +706,7 @@
"9488402": 59860,
"9556602": 4744,
"9561202": 124451,
"9575701": 6559,
"9596802": 230,
"9610402": 797,
"9694102": 4997,
Expand Down Expand Up @@ -907,6 +914,7 @@
"10346102": 2910452,
"10346502": 2751897,
"10346602": 2577169,
"10346702": 3239498,
"10362102": 2801796,
"10362802": 2452793,
"10366602": 2627805,
Expand Down Expand Up @@ -1228,6 +1236,8 @@
"10963002": 718605,
"10974701": 1201323,
"10975901": 1234314,
"10981502": 27922,
"10981602": 40965,
"10981702": 2845643,
"10982701": 14366,
"10982801": 235404,
Expand All @@ -1242,6 +1252,8 @@
"10990802": 2885241,
"10992502": 3065585,
"10992602": 3174877,
"10992702": 2743481,
"10992802": 2189184,
"10993002": 371716,
"10993102": 764071,
"10993202": 3178850,
Expand Down Expand Up @@ -1274,5 +1286,50 @@
"11010302": 2421367,
"11010402": 1702015,
"11010502": 1701387,
"11014802": 2798855,
"11018102": 2068818,
"11037402": 144154,
"11041602": 3099453,
"11041702": 3060243,
"11042102": 3114947,
"11042202": 2537677,
"11044202": 2767214,
"11044302": 2598334,
"11044402": 2798850,
"11044502": 3028051,
"11044602": 3135627,
"11044702": 3135629,
"11045002": 3263124,
"11045102": 3263553,
"11045502": 3252565,
"11045602": 3252541,
"11045802": 3239633,
"11046302": 1913905,
"11046402": 1913910,
"11046602": 3267539,
"11046702": 3251845,
"11046802": 1834990,
"11047402": 1125022,
"11052502": 3276301,
"11053202": 2920800,
"11053302": 77072,
"11053401": 2962828,
"11053501": 2233871,
"11053602": 3249770,
"11053701": 1829,
"11053801": 3194756,
"11053901": 3194757,
"11054002": 3110279,
"11054202": 923,
"11054302": 2229855,
"11054401": 5726,
"11054502": 3158937,
"11054602": 3180018,
"11054702": 3179873,
"11054801": 425451,
"11060602": 3156280,
"11060702": 960050,
"11060802": 233045,
"11067302": 2823194,
"54077902102": 6760
}
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Tappdopolet",
"description": "Gets information about beer from Untappd and displays it inline at Vinmonopolet.",
"version": "1.1.3",
"version": "1.1.4",

"permissions": ["*://*.untappd.com/*"],

Expand Down

0 comments on commit d43e20d

Please sign in to comment.