mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-01 09:00:01 +01:00
fix updating of app status
This commit is contained in:
@@ -32,7 +32,23 @@ DB_HOST = os.getenv("DB_HOST")
|
||||
DB_PORT = os.getenv("DB_PORT")
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
DB_PASSWORD = os.getenv("DB_PASSWORD")
|
||||
|
||||
TABLES = [
|
||||
User,
|
||||
App,
|
||||
ProjectDescription,
|
||||
UserStories,
|
||||
UserTasks,
|
||||
Architecture,
|
||||
DevelopmentPlanning,
|
||||
DevelopmentSteps,
|
||||
EnvironmentSetup,
|
||||
Development,
|
||||
FileSnapshot,
|
||||
CommandRuns,
|
||||
UserApps,
|
||||
UserInputs,
|
||||
File,
|
||||
]
|
||||
|
||||
def get_created_apps():
|
||||
return [model_to_dict(app) for app in App.select()]
|
||||
@@ -94,16 +110,18 @@ def get_user(user_id=None, email=None):
|
||||
|
||||
|
||||
def save_app(project):
|
||||
args = project.args
|
||||
app_status = getattr(project, "current_step", None)
|
||||
|
||||
try:
|
||||
args = project.args
|
||||
app = App.get(App.id == args['app_id'])
|
||||
for key, value in args.items():
|
||||
if key != 'app_id' and value is not None:
|
||||
setattr(app, key, value)
|
||||
app.status = project.current_step
|
||||
|
||||
app.status = app_status
|
||||
app.save()
|
||||
except DoesNotExist:
|
||||
args = project.args
|
||||
if args.get('user_id') is not None:
|
||||
try:
|
||||
user = get_user(user_id=args['user_id'])
|
||||
@@ -119,7 +137,7 @@ def save_app(project):
|
||||
user=user,
|
||||
app_type=args.get('app_type'),
|
||||
name=args.get('name'),
|
||||
status=project.current_step
|
||||
status=app_status
|
||||
)
|
||||
|
||||
return app
|
||||
@@ -401,44 +419,12 @@ def save_file_description(project, path, name, description):
|
||||
|
||||
def create_tables():
|
||||
with database:
|
||||
database.create_tables([
|
||||
User,
|
||||
App,
|
||||
ProjectDescription,
|
||||
UserStories,
|
||||
UserTasks,
|
||||
Architecture,
|
||||
DevelopmentPlanning,
|
||||
DevelopmentSteps,
|
||||
EnvironmentSetup,
|
||||
Development,
|
||||
FileSnapshot,
|
||||
CommandRuns,
|
||||
UserApps,
|
||||
UserInputs,
|
||||
File,
|
||||
])
|
||||
database.create_tables(TABLES)
|
||||
|
||||
|
||||
def drop_tables():
|
||||
with database.atomic():
|
||||
for table in [
|
||||
User,
|
||||
App,
|
||||
ProjectDescription,
|
||||
UserStories,
|
||||
UserTasks,
|
||||
Architecture,
|
||||
DevelopmentPlanning,
|
||||
DevelopmentSteps,
|
||||
EnvironmentSetup,
|
||||
Development,
|
||||
FileSnapshot,
|
||||
CommandRuns,
|
||||
UserApps,
|
||||
UserInputs,
|
||||
File,
|
||||
]:
|
||||
for table in TABLES:
|
||||
if DATABASE_TYPE == "postgres":
|
||||
sql = f'DROP TABLE IF EXISTS "{table._meta.table_name}" CASCADE'
|
||||
elif DATABASE_TYPE == "sqlite":
|
||||
@@ -484,11 +470,8 @@ def create_database():
|
||||
|
||||
|
||||
def tables_exist():
|
||||
tables = [User, App, ProjectDescription, UserStories, UserTasks, Architecture, DevelopmentPlanning,
|
||||
DevelopmentSteps, EnvironmentSetup, Development, FileSnapshot, CommandRuns, UserApps, UserInputs, File]
|
||||
|
||||
if DATABASE_TYPE == "postgres":
|
||||
for table in tables:
|
||||
for table in TABLES:
|
||||
try:
|
||||
database.get_tables().index(table._meta.table_name)
|
||||
except ValueError:
|
||||
|
||||
@@ -8,4 +8,4 @@ class App(BaseModel):
|
||||
user = ForeignKeyField(User, backref='apps')
|
||||
app_type = CharField(null=True)
|
||||
name = CharField(null=True)
|
||||
status = CharField(default='started')
|
||||
status = CharField(null=True)
|
||||
@@ -94,7 +94,7 @@ class Project:
|
||||
self.architecture = self.architect.get_architecture()
|
||||
|
||||
self.developer = Developer(self)
|
||||
self.developer.set_up_environment();
|
||||
self.developer.set_up_environment()
|
||||
|
||||
self.tech_lead = TechLead(self)
|
||||
self.development_plan = self.tech_lead.create_development_plan()
|
||||
@@ -129,12 +129,6 @@ class Project:
|
||||
break
|
||||
# TODO END
|
||||
|
||||
self.developer = Developer(self)
|
||||
print(json.dumps({
|
||||
"project_stage": "environment_setup"
|
||||
}), type='info')
|
||||
self.developer.set_up_environment()
|
||||
|
||||
print(json.dumps({
|
||||
"project_stage": "coding"
|
||||
}), type='info')
|
||||
|
||||
@@ -13,7 +13,7 @@ from helpers.AgentConvo import AgentConvo
|
||||
from utils.utils import should_execute_step, array_of_objects_to_string, generate_app_data
|
||||
from helpers.cli import run_command_until_success, execute_command_and_check_cli_response
|
||||
from const.function_calls import FILTER_OS_TECHNOLOGIES, EXECUTE_COMMANDS, GET_TEST_TYPE, IMPLEMENT_TASK
|
||||
from database.database import save_progress, get_progress_steps
|
||||
from database.database import save_progress, get_progress_steps, update_app_status
|
||||
from utils.utils import get_os_info
|
||||
|
||||
ENVIRONMENT_SETUP_STEP = 'environment_setup'
|
||||
@@ -27,6 +27,7 @@ class Developer(Agent):
|
||||
|
||||
def start_coding(self):
|
||||
self.project.current_step = 'coding'
|
||||
update_app_status(self.project.args['app_id'], self.project.current_step)
|
||||
|
||||
if self.project.skip_steps is None:
|
||||
self.project.skip_steps = False if ('skip_until_dev_step' in self.project.args and self.project.args['skip_until_dev_step'] == '0') else True
|
||||
|
||||
@@ -43,7 +43,6 @@ def get_custom_print(args):
|
||||
|
||||
if 'type' not in kwargs:
|
||||
kwargs['type'] = 'verbose'
|
||||
return
|
||||
elif kwargs['type'] == MESSAGE_TYPE['local']:
|
||||
local_print(*args, **kwargs)
|
||||
return
|
||||
|
||||
@@ -42,6 +42,7 @@ def get_arguments():
|
||||
|
||||
arguments['app_type'] = app.app_type
|
||||
arguments['name'] = app.name
|
||||
arguments['step'] = app.status
|
||||
# Add any other fields from the App model you wish to include
|
||||
|
||||
print(green_bold('\n------------------ LOADING PROJECT ----------------------'))
|
||||
|
||||
Reference in New Issue
Block a user