{"action":"created","comment":{"url":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/23119860","id":23119860,"diff_hunk":"@@ -106,53 +203,72 @@ def logTaskCreatedSQL(taskManager, commandReplacementDic, taskUUID, arguments):\n     taskexec = taskManager.execute\n     fileName = os.path.basename(os.path.abspath(commandReplacementDic[\"%relativeLocation%\"]))\n \n-    databaseInterface.runSQL(\"\"\"INSERT INTO Tasks (taskUUID, jobUUID, fileUUID, fileName, exec, arguments, createdTime)\n-        VALUES (%s, %s, %s, %s, %s, %s, %s)\"\"\",\n-        (taskUUID, jobUUID, fileUUID, fileName,\n-         taskexec, arguments, databaseInterface.getUTCDate())\n-    )\n-\n-def logTaskAssignedSQL(taskUUID, client, date):\n-    databaseInterface.runSQL(\n-        \"\"\"UPDATE Tasks SET startTime=%s, client=%s WHERE taskUUID=%s;\"\"\",\n-        (date, client, taskUUID)\n-    )\n+    Task.objects.create(taskuuid=taskUUID,\n+                        job_id=jobUUID,\n+                        fileuuid=fileUUID,\n+                        filename=fileName,\n+                        execution=taskexec,\n+                        arguments=arguments,\n+                        createdtime=getUTCDate())\n \n def logTaskCompletedSQL(task):\n+    \"\"\"\n+    Fetches execution data from the completed task and logs it to the database.\n+    Updates the entry in the Tasks table with data in the provided task.\n+    Saves the following fields: exitCode, stdOut, stdError\n+\n+    :param task:\n+    \"\"\"\n     print \"Logging task output to db\", task.UUID\n     taskUUID = task.UUID.__str__()\n     exitCode = task.results[\"exitCode\"].__str__()\n     stdOut = task.results[\"stdOut\"]\n     stdError = task.results[\"stdError\"]\n \n-    databaseInterface.runSQL(\n-        \"\"\"UPDATE Tasks SET endTime=%s, exitCode=%s, stdOut=%s, stdError=%s\n-           WHERE taskUUID=%s\"\"\",\n-        (databaseInterface.getUTCDate(), exitCode, stdOut, stdError, taskUUID)\n-    )\n+    task = Task.objects.get(taskuuid=taskUUID)\n+    task.endtime = getUTCDate()\n+    task.exitcode = exitCode\n+    task.stdout = stdOut\n+    task.stderror = stdError\n+    task.save()\n \n def logJobCreatedSQL(job):\n-    separator = databaseInterface.getSeparator()\n+    \"\"\"\n+    Logs a job's properties into the Jobs table in the database.\n+\n+    :param jobChainLink job: A jobChainLink instance.\n+    :returns None:    \n+    \"\"\"\n     unitUUID =  job.unit.UUID\n-    decDate = databaseInterface.getDeciDate(\".\" + job.createdDate.split(\".\")[-1])\n+    decDate = getDeciDate(\".\" + job.createdDate.split(\".\")[-1])\n     if job.unit.owningUnit != None:\n         unitUUID = job.unit.owningUnit.UUID \n-    databaseInterface.runSQL(\"\"\"INSERT INTO Jobs (jobUUID, jobType, directory, SIPUUID, currentStep, unitType, microserviceGroup, createdTime, createdTimeDec, MicroServiceChainLinksPK, subJobOf)\n-        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\"\"\",\n-        (job.UUID, job.description, job.unit.currentPath, unitUUID,\n-         \"Executing command(s)\", job.unit.__class__.__name__,\n-         str(job.microserviceGroup), job.createdDate, decDate, str(job.pk),\n-         str(job.subJobOf))\n-    )\n-    #TODO -un hardcode executing exeCommand\n-\n-def logJobStepCompletedSQL(job):\n-    databaseInterface.runSQL(\"\"\"INSERT INTO jobStepCompleted (jobUUID, step, completedTime)\n-        VALUES (%s, %s, %s)\"\"\",\n-        (job.UUID, job.step, databaseInterface.getUTCDate())\n-    )\n-\n-def fileWasRemoved(fileUUID, utcDate=databaseInterface.getUTCDate(), eventDetail = \"\", eventOutcomeDetailNote = \"\", eventOutcome=\"\"):\n+    job = Job(jobuuid=job.UUID,","path":"src/archivematicaCommon/lib/databaseFunctions.py","position":304,"original_position":304,"commit_id":"fda82ffefa80ab9310b78f3a4b80f3ca2063ab9f","original_commit_id":"fda82ffefa80ab9310b78f3a4b80f3ca2063ab9f","user":{"login":"Hwesta","id":3166226,"avatar_url":"https://avatars.githubusercontent.com/u/3166226?v=3","gravatar_id":"","url":"https://api.github.com/users/Hwesta","html_url":"https://github.com/Hwesta","followers_url":"https://api.github.com/users/Hwesta/followers","following_url":"https://api.github.com/users/Hwesta/following{/other_user}","gists_url":"https://api.github.com/users/Hwesta/gists{/gist_id}","starred_url":"https://api.github.com/users/Hwesta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hwesta/subscriptions","organizations_url":"https://api.github.com/users/Hwesta/orgs","repos_url":"https://api.github.com/users/Hwesta/repos","events_url":"https://api.github.com/users/Hwesta/events{/privacy}","received_events_url":"https://api.github.com/users/Hwesta/received_events","type":"User","site_admin":false},"body":"Redefinition of variable name - job is both the parameter jobChainLink and the newly created Job. ","created_at":"2015-01-17T00:50:20Z","updated_at":"2015-01-17T00:50:20Z","html_url":"https://github.com/artefactual/archivematica/pull/98#discussion_r23119860","pull_request_url":"https://api.github.com/repos/artefactual/archivematica/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/23119860"},"html":{"href":"https://github.com/artefactual/archivematica/pull/98#discussion_r23119860"},"pull_request":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/artefactual/archivematica/pulls/98","id":20081364,"html_url":"https://github.com/artefactual/archivematica/pull/98","diff_url":"https://github.com/artefactual/archivematica/pull/98.diff","patch_url":"https://github.com/artefactual/archivematica/pull/98.patch","issue_url":"https://api.github.com/repos/artefactual/archivematica/issues/98","number":98,"state":"open","locked":false,"title":"Replace databaseInterface with Django models","user":{"login":"mistydemeo","id":780485,"avatar_url":"https://avatars.githubusercontent.com/u/780485?v=3","gravatar_id":"","url":"https://api.github.com/users/mistydemeo","html_url":"https://github.com/mistydemeo","followers_url":"https://api.github.com/users/mistydemeo/followers","following_url":"https://api.github.com/users/mistydemeo/following{/other_user}","gists_url":"https://api.github.com/users/mistydemeo/gists{/gist_id}","starred_url":"https://api.github.com/users/mistydemeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistydemeo/subscriptions","organizations_url":"https://api.github.com/users/mistydemeo/orgs","repos_url":"https://api.github.com/users/mistydemeo/repos","events_url":"https://api.github.com/users/mistydemeo/events{/privacy}","received_events_url":"https://api.github.com/users/mistydemeo/received_events","type":"User","site_admin":false},"body":"~~`databaseInterface` is still imported in a few places in MCPServer, primarily for the `getUTCTime` function that will be moved elsewhere, and for database locking that may be removeable.~~\r\n\r\nSee comments below.","created_at":"2014-08-20T23:26:42Z","updated_at":"2015-01-17T00:50:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a081233f665439765be3eeffd816a38ef158a90e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/artefactual/archivematica/pulls/98/commits","review_comments_url":"https://api.github.com/repos/artefactual/archivematica/pulls/98/comments","review_comment_url":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/{number}","comments_url":"https://api.github.com/repos/artefactual/archivematica/issues/98/comments","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/fda82ffefa80ab9310b78f3a4b80f3ca2063ab9f","head":{"label":"artefactual:dev/issue-7137-mcpserver_models","ref":"dev/issue-7137-mcpserver_models","sha":"fda82ffefa80ab9310b78f3a4b80f3ca2063ab9f","user":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"repo":{"id":5811958,"name":"archivematica","full_name":"artefactual/archivematica","owner":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/artefactual/archivematica","description":"Free and open-source digital preservation system designed to maintain standards-based, long-term access to collections of digital objects.","fork":false,"url":"https://api.github.com/repos/artefactual/archivematica","forks_url":"https://api.github.com/repos/artefactual/archivematica/forks","keys_url":"https://api.github.com/repos/artefactual/archivematica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artefactual/archivematica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artefactual/archivematica/teams","hooks_url":"https://api.github.com/repos/artefactual/archivematica/hooks","issue_events_url":"https://api.github.com/repos/artefactual/archivematica/issues/events{/number}","events_url":"https://api.github.com/repos/artefactual/archivematica/events","assignees_url":"https://api.github.com/repos/artefactual/archivematica/assignees{/user}","branches_url":"https://api.github.com/repos/artefactual/archivematica/branches{/branch}","tags_url":"https://api.github.com/repos/artefactual/archivematica/tags","blobs_url":"https://api.github.com/repos/artefactual/archivematica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artefactual/archivematica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artefactual/archivematica/git/refs{/sha}","trees_url":"https://api.github.com/repos/artefactual/archivematica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/{sha}","languages_url":"https://api.github.com/repos/artefactual/archivematica/languages","stargazers_url":"https://api.github.com/repos/artefactual/archivematica/stargazers","contributors_url":"https://api.github.com/repos/artefactual/archivematica/contributors","subscribers_url":"https://api.github.com/repos/artefactual/archivematica/subscribers","subscription_url":"https://api.github.com/repos/artefactual/archivematica/subscription","commits_url":"https://api.github.com/repos/artefactual/archivematica/commits{/sha}","git_commits_url":"https://api.github.com/repos/artefactual/archivematica/git/commits{/sha}","comments_url":"https://api.github.com/repos/artefactual/archivematica/comments{/number}","issue_comment_url":"https://api.github.com/repos/artefactual/archivematica/issues/comments/{number}","contents_url":"https://api.github.com/repos/artefactual/archivematica/contents/{+path}","compare_url":"https://api.github.com/repos/artefactual/archivematica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artefactual/archivematica/merges","archive_url":"https://api.github.com/repos/artefactual/archivematica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artefactual/archivematica/downloads","issues_url":"https://api.github.com/repos/artefactual/archivematica/issues{/number}","pulls_url":"https://api.github.com/repos/artefactual/archivematica/pulls{/number}","milestones_url":"https://api.github.com/repos/artefactual/archivematica/milestones{/number}","notifications_url":"https://api.github.com/repos/artefactual/archivematica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artefactual/archivematica/labels{/name}","releases_url":"https://api.github.com/repos/artefactual/archivematica/releases{/id}","created_at":"2012-09-14T16:43:38Z","updated_at":"2014-12-15T16:30:21Z","pushed_at":"2015-01-14T23:56:13Z","git_url":"git://github.com/artefactual/archivematica.git","ssh_url":"git@github.com:artefactual/archivematica.git","clone_url":"https://github.com/artefactual/archivematica.git","svn_url":"https://github.com/artefactual/archivematica","homepage":"http://www.archivematica.org","size":31435,"stargazers_count":51,"watchers_count":51,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":14,"forks":13,"open_issues":14,"watchers":51,"default_branch":"stable/1.3.x"}},"base":{"label":"artefactual:qa/1.x","ref":"qa/1.x","sha":"511035e177616f2cb64888e4fbf43406a2583673","user":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"repo":{"id":5811958,"name":"archivematica","full_name":"artefactual/archivematica","owner":{"login":"artefactual","id":1163545,"avatar_url":"https://avatars.githubusercontent.com/u/1163545?v=3","gravatar_id":"","url":"https://api.github.com/users/artefactual","html_url":"https://github.com/artefactual","followers_url":"https://api.github.com/users/artefactual/followers","following_url":"https://api.github.com/users/artefactual/following{/other_user}","gists_url":"https://api.github.com/users/artefactual/gists{/gist_id}","starred_url":"https://api.github.com/users/artefactual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artefactual/subscriptions","organizations_url":"https://api.github.com/users/artefactual/orgs","repos_url":"https://api.github.com/users/artefactual/repos","events_url":"https://api.github.com/users/artefactual/events{/privacy}","received_events_url":"https://api.github.com/users/artefactual/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/artefactual/archivematica","description":"Free and open-source digital preservation system designed to maintain standards-based, long-term access to collections of digital objects.","fork":false,"url":"https://api.github.com/repos/artefactual/archivematica","forks_url":"https://api.github.com/repos/artefactual/archivematica/forks","keys_url":"https://api.github.com/repos/artefactual/archivematica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artefactual/archivematica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artefactual/archivematica/teams","hooks_url":"https://api.github.com/repos/artefactual/archivematica/hooks","issue_events_url":"https://api.github.com/repos/artefactual/archivematica/issues/events{/number}","events_url":"https://api.github.com/repos/artefactual/archivematica/events","assignees_url":"https://api.github.com/repos/artefactual/archivematica/assignees{/user}","branches_url":"https://api.github.com/repos/artefactual/archivematica/branches{/branch}","tags_url":"https://api.github.com/repos/artefactual/archivematica/tags","blobs_url":"https://api.github.com/repos/artefactual/archivematica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artefactual/archivematica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artefactual/archivematica/git/refs{/sha}","trees_url":"https://api.github.com/repos/artefactual/archivematica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artefactual/archivematica/statuses/{sha}","languages_url":"https://api.github.com/repos/artefactual/archivematica/languages","stargazers_url":"https://api.github.com/repos/artefactual/archivematica/stargazers","contributors_url":"https://api.github.com/repos/artefactual/archivematica/contributors","subscribers_url":"https://api.github.com/repos/artefactual/archivematica/subscribers","subscription_url":"https://api.github.com/repos/artefactual/archivematica/subscription","commits_url":"https://api.github.com/repos/artefactual/archivematica/commits{/sha}","git_commits_url":"https://api.github.com/repos/artefactual/archivematica/git/commits{/sha}","comments_url":"https://api.github.com/repos/artefactual/archivematica/comments{/number}","issue_comment_url":"https://api.github.com/repos/artefactual/archivematica/issues/comments/{number}","contents_url":"https://api.github.com/repos/artefactual/archivematica/contents/{+path}","compare_url":"https://api.github.com/repos/artefactual/archivematica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artefactual/archivematica/merges","archive_url":"https://api.github.com/repos/artefactual/archivematica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artefactual/archivematica/downloads","issues_url":"https://api.github.com/repos/artefactual/archivematica/issues{/number}","pulls_url":"https://api.github.com/repos/artefactual/archivematica/pulls{/number}","milestones_url":"https://api.github.com/repos/artefactual/archivematica/milestones{/number}","notifications_url":"https://api.github.com/repos/artefactual/archivematica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artefactual/archivematica/labels{/name}","releases_url":"https://api.github.com/repos/artefactual/archivematica/releases{/id}","created_at":"2012-09-14T16:43:38Z","updated_at":"2014-12-15T16:30:21Z","pushed_at":"2015-01-14T23:56:13Z","git_url":"git://github.com/artefactual/archivematica.git","ssh_url":"git@github.com:artefactual/archivematica.git","clone_url":"https://github.com/artefactual/archivematica.git","svn_url":"https://github.com/artefactual/archivematica","homepage":"http://www.archivematica.org","size":31435,"stargazers_count":51,"watchers_count":51,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":14,"forks":13,"open_issues":14,"watchers":51,"default_branch":"stable/1.3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/98"},"html":{"href":"https://github.com/artefactual/archivematica/pull/98"},"issue":{"href":"https://api.github.com/repos/artefactual/archivematica/issues/98"},"comments":{"href":"https://api.github.com/repos/artefactual/archivematica/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/artefactual/archivematica/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/artefactual/archivematica/statuses/fda82ffefa80ab9310b78f3a4b80f3ca2063ab9f"}}}}