diff --git a/app/commands/commands.py b/app/commands/commands.py index 6f23392..42efb0b 100644 --- a/app/commands/commands.py +++ b/app/commands/commands.py @@ -43,8 +43,8 @@ def feed_from_irap(csv_file_name): secondname_key = 'prénom' project_key = 'PROJETS' service_key = 'Groupe métier' - typology_title = 'TYPOLOGIE' - thematic_title = 'thématique' + # typology_title = 'TYPOLOGIE' + # thematic_title = 'thématique' # Get the columns values # @@ -82,13 +82,18 @@ def feed_from_irap(csv_file_name): db.session.commit() # Feed periods names - # Todo: should come from year column name + # Todo: are statically built, + # should come from year column name. # for p in range(2011, 2030): n_p = Period(name=f"{p}") db.session.add(n_p) db.session.commit() + # Add one default capacity + db.session.add(Capacity(name="Travailleur")) + db.session.commit() + # Now feed the charges. # # At least one for each csv row @@ -98,6 +103,7 @@ def feed_from_irap(csv_file_name): p = Project.query.filter(Project.name == r[project_key]).one() a = Agent.query.filter(Agent.firstname == r[firstname_key], Agent.secondname == r[secondname_key]).one() s = Service.query.filter(Service.name == r[service_key]).one() + c = Capacity.query.first() for period_name in range(2011, 2030): t = Period.query.filter(Period.name == period_name).one() charge = r[f"{period_name}"] @@ -110,7 +116,7 @@ def feed_from_irap(csv_file_name): n_c = Charge(agent_id=a.id, project_id=p.id, service_id=s.id, - # capacity_id=0, + capacity_id=c.id, period_id=t.id, charge_rate=charge) db.session.add(n_c) -- libgit2 0.21.2