Browse Source

Sonstiges

Robert Bedner 3 years ago
parent
commit
c1ae2f6ded
4 changed files with 95 additions and 3 deletions
  1. 1 1
      Portal/Tasks/config/info/versand.csv
  2. 8 2
      crewmeister.py
  3. 24 0
      gcstarter/SQL/brass.sql
  4. 62 0
      sandbox/useless.py

+ 1 - 1
Portal/Tasks/config/info/versand.csv

@@ -8,7 +8,7 @@ GAPS_Vers_Mo_Mi_Fr.xml;Versand mo mi fr;_Service_offene_Auftraege_;torsten.herzo
 GAPS_Vers_Mo_Mi_Fr.xml;Versand mo mi fr;_Service_offene_Auftraege_;torsten.herzog@lausse.de;SC_VK_Serviceber;Service Umsatz nach Serviceberater;J;J;0;N;aftersales
 GAPS_Vers_Mo_Mi_Fr.xml;Versand mo mi fr;_Service_offene_Auftraege_;volker.lausse@lausse.de;Umsatz_Bruttoertrag_Opel;Opel_Umsatz_BE;J;J;0;N;belege_bank
 GAPS_Vers_Mo_Mi_Fr.xml;Versand mo mi fr;_Service_offene_Auftraege_;anke.hymoeller@lausse.de;Umsatz_Bruttoertrag_Opel;Opel_Umsatz_BE;J;J;0;N;belege_bank
-GAPS_Vers_Tag.xml;Versand Tag;_Finanzen_;robert.bedner2@gmail.com;Umsatz_Bruttoertrag_Opel;Opel_Umsatz_BE;J;J;0;N;belege_bank
+GAPS_Vers_Tag.xml;Versand Tag;_Finanzen_;robert.bedner@gmail.com;Umsatz_Bruttoertrag_Opel;Opel_Umsatz_BE;J;J;0;N;belege_bank
 GAPS_Vers_Tag.xml;Versand Tag;_Finanzen_;volker.lausse@lausse.de;Umsatz_Bruttoertrag_Opel;Opel_Umsatz_BE;J;J;0;N;belege_bank
 GAPS_Vers_Tag.xml;Versand Tag;_Finanzen_;torsten.herzog@lausse.de;Umsatz_Bruttoertrag_Aftersales;Umsatz Bruttoertrag Aftersales Gesamt;J;J;0;N;belege_bank
 GAPS_Vers_Tag.xml;Versand Tag;_Finanzen_;paul.jungerberg@lausse.de;Umsatz_Bruttoertrag_Aftersales;Umsatz Bruttoertrag Aftersales FED;J;J;5;N;belege_bank

+ 8 - 2
crewmeister.py

@@ -25,6 +25,11 @@ def type_id(x):
     return "anwesend"
 
 
+def timestamp_to_time(ts):
+    dt = datetime.datetime.fromisoformat(ts)
+    return dt.strftime('%H:%M:%S')
+
+
 class crewmeister:
     webservice = "https://api.crewmeister.com/api/v2"
 
@@ -63,7 +68,7 @@ class crewmeister:
         r = requests.get(self.webservice + querystring, params, cookies=self.cookies)
         try:
             df = pd.DataFrame(r.json()['payload'])
-            if 'userId' not in df.columns:
+            if df.shape[0] > 0 and 'userId' not in df.columns:
                 df['userId'] = df['groupBy'].map(lambda x: x['userId'])
             for (key, (col, map_fun)) in cols.items():
                 df[key] = df[col].map(map_fun)
@@ -106,7 +111,8 @@ class crewmeister:
 if __name__ == '__main__':
     cm = crewmeister()
     user = cm.statistics().loc[86043]
-    print("Gerade anwesend: " + user['clockInTimestamp'])
+    print("Name: " + user['email'])
+    print("Gerade anwesend: " + timestamp_to_time(user['clockInTimestamp']))
     print("geplante Abwesenheit heute: " + type_id(user['absence_today']))
     print("Urlaub Jahresanfang: " + str(user['absence_vac_prev']))
     print("Urlaub genommen: " + str(user['absence_vacation']))

File diff suppressed because it is too large
+ 24 - 0
gcstarter/SQL/brass.sql


+ 62 - 0
sandbox/useless.py

@@ -0,0 +1,62 @@
+from typing import List
+
+
+def useless_flight(schedule: List) -> List:
+    result = []
+    nodes = [s for s, d, _ in schedule] + [d for s, d, _ in schedule]
+
+    for i, e in enumerate(schedule):
+        x, y, p = e
+        graph = sorted([z for z in schedule if z != e], key=lambda x: x[2])
+
+        if nodes.count(x) > 1 and nodes.count(y) > 1 and route_price(graph, x, y, [], p) < p:
+            result.append(i)
+    return result
+
+
+def route_price(graph, source, dest, visited, best=100000, price=0):
+    if source == dest:
+        return price
+
+    for s, d, p in graph:
+        if d == source:
+            s, d = d, s
+        if s == source and d not in visited and price + p < best:
+            p_new = route_price(graph, d, dest, visited + [s], best, price + p)
+            best = min(best, p_new)
+    return best
+
+
+if __name__ == '__main__':
+    print("Example:")
+    print(useless_flight([['A', 'B', 50],
+                          ['B', 'C', 40],
+                          ['A', 'C', 100]]))
+
+    # These "asserts" are used for self-checking and not for an auto-testing
+    assert useless_flight([['A', 'B', 50],
+                           ['B', 'C', 40],
+                           ['A', 'C', 100]]) == [2]
+    assert useless_flight([['A', 'B', 50],
+                           ['B', 'C', 40],
+                           ['A', 'C', 90]]) == []
+    assert useless_flight([['A', 'B', 50],
+                           ['B', 'C', 40],
+                           ['A', 'C', 40]]) == []
+    assert useless_flight([['A', 'C', 10],
+                           ['C', 'B', 10],
+                           ['C', 'E', 10],
+                           ['C', 'D', 10],
+                           ['B', 'E', 25],
+                           ['A', 'D', 20],
+                           ['D', 'F', 50],
+                           ['E', 'F', 90]]) == [4, 7]
+    assert useless_flight([["A", "E", 45], ["A", "H", 85], ["A", "K", 60], ["A", "N", 20], ["B", "C", 90],
+                           ["B", "Q", 70], ["B", "X", 60], ["B", "Y", 100], ["C", "R", 55], ["C", "X", 30],
+                           ["D", "F", 10], ["D", "T", 50], ["D", "U", 75], ["D", "V", 35], ["E", "H", 55],
+                           ["E", "J", 40], ["E", "M", 35], ["F", "J", 95], ["F", "M", 10], ["G", "N", 75],
+                           ["G", "P", 75], ["G", "W", 40], ["H", "V", 15], ["I", "O", 10], ["I", "Q", 10],
+                           ["I", "S", 70], ["J", "M", 80], ["J", "V", 20], ["K", "U", 85], ["K", "V", 80],
+                           ["K", "Y", 35], ["L", "P", 15], ["L", "R", 40], ["L", "X", 50], ["N", "P", 70],
+                           ["N", "W", 30], ["O", "Q", 40], ["O", "S", 55], ["O", "U", 45], ["P", "W", 90],
+                           ["Q", "Y", 10], ["R", "X", 95], ["S", "T", 100], ["T", "U", 30], ["W", "Y", 15]]) == [7, 17, 19, 25, 26, 36, 41]

Some files were not shown because too many files changed in this diff