Commit abfde781 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch '213808-add-scheduled-at-field-to-jira-imports' into 'master'

Add scheduled_at field to jira_imports table

Closes #213808

See merge request gitlab-org/gitlab!30284
parents 4140695e 455083c2
...@@ -7,9 +7,10 @@ module Types ...@@ -7,9 +7,10 @@ module Types
class JiraImportType < BaseObject class JiraImportType < BaseObject
graphql_name 'JiraImport' graphql_name 'JiraImport'
field :scheduled_at, Types::TimeType, null: true, field :created_at, Types::TimeType, null: true,
method: :created_at,
description: 'Timestamp of when the Jira import was created' description: 'Timestamp of when the Jira import was created'
field :scheduled_at, Types::TimeType, null: true,
description: 'Timestamp of when the Jira import was scheduled'
field :scheduled_by, Types::UserType, null: true, field :scheduled_by, Types::UserType, null: true,
description: 'User that started the Jira import' description: 'User that started the Jira import'
field :jira_project_key, GraphQL::STRING_TYPE, null: false, field :jira_project_key, GraphQL::STRING_TYPE, null: false,
......
...@@ -46,7 +46,7 @@ class JiraImportState < ApplicationRecord ...@@ -46,7 +46,7 @@ class JiraImportState < ApplicationRecord
after_transition initial: :scheduled do |state, _| after_transition initial: :scheduled do |state, _|
state.run_after_commit do state.run_after_commit do
job_id = Gitlab::JiraImport::Stage::StartImportWorker.perform_async(project.id) job_id = Gitlab::JiraImport::Stage::StartImportWorker.perform_async(project.id)
state.update(jid: job_id) if job_id state.update(jid: job_id, scheduled_at: Time.now) if job_id
end end
end end
......
---
title: Add scheduled_at field to jira_imports table
merge_request: 30284
author:
type: added
# frozen_string_literal: true
class AddScheduledAtToJiraImports < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :jira_imports, :scheduled_at, :datetime_with_timezone
end
end
...@@ -3433,7 +3433,8 @@ CREATE TABLE public.jira_imports ( ...@@ -3433,7 +3433,8 @@ CREATE TABLE public.jira_imports (
status smallint DEFAULT 0 NOT NULL, status smallint DEFAULT 0 NOT NULL,
jid character varying(255), jid character varying(255),
jira_project_key character varying(255) NOT NULL, jira_project_key character varying(255) NOT NULL,
jira_project_name character varying(255) NOT NULL jira_project_name character varying(255) NOT NULL,
scheduled_at timestamp with time zone
); );
CREATE SEQUENCE public.jira_imports_id_seq CREATE SEQUENCE public.jira_imports_id_seq
...@@ -13521,6 +13522,7 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13521,6 +13522,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200423080334 20200423080334
20200423080607 20200423080607
20200423081409 20200423081409
20200423101529
20200424050250 20200424050250
20200427064130 20200427064130
\. \.
......
...@@ -4509,13 +4509,18 @@ Represents untyped JSON ...@@ -4509,13 +4509,18 @@ Represents untyped JSON
scalar JSON scalar JSON
type JiraImport { type JiraImport {
"""
Timestamp of when the Jira import was created
"""
createdAt: Time
""" """
Project key for the imported Jira project Project key for the imported Jira project
""" """
jiraProjectKey: String! jiraProjectKey: String!
""" """
Timestamp of when the Jira import was created Timestamp of when the Jira import was scheduled
""" """
scheduledAt: Time scheduledAt: Time
......
...@@ -12767,6 +12767,20 @@ ...@@ -12767,6 +12767,20 @@
"name": "JiraImport", "name": "JiraImport",
"description": null, "description": null,
"fields": [ "fields": [
{
"name": "createdAt",
"description": "Timestamp of when the Jira import was created",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "jiraProjectKey", "name": "jiraProjectKey",
"description": "Project key for the imported Jira project", "description": "Project key for the imported Jira project",
...@@ -12787,7 +12801,7 @@ ...@@ -12787,7 +12801,7 @@
}, },
{ {
"name": "scheduledAt", "name": "scheduledAt",
"description": "Timestamp of when the Jira import was created", "description": "Timestamp of when the Jira import was scheduled",
"args": [ "args": [
], ],
......
...@@ -677,8 +677,9 @@ Autogenerated return type of IssueSetWeight ...@@ -677,8 +677,9 @@ Autogenerated return type of IssueSetWeight
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `createdAt` | Time | Timestamp of when the Jira import was created |
| `jiraProjectKey` | String! | Project key for the imported Jira project | | `jiraProjectKey` | String! | Project key for the imported Jira project |
| `scheduledAt` | Time | Timestamp of when the Jira import was created | | `scheduledAt` | Time | Timestamp of when the Jira import was scheduled |
| `scheduledBy` | User | User that started the Jira import | | `scheduledBy` | User | User that started the Jira import |
## JiraImportStartPayload ## JiraImportStartPayload
......
...@@ -6,6 +6,6 @@ describe GitlabSchema.types['JiraImport'] do ...@@ -6,6 +6,6 @@ describe GitlabSchema.types['JiraImport'] do
it { expect(described_class.graphql_name).to eq('JiraImport') } it { expect(described_class.graphql_name).to eq('JiraImport') }
it 'has the expected fields' do it 'has the expected fields' do
expect(described_class).to have_graphql_fields(:jira_project_key, :scheduled_at, :scheduled_by) expect(described_class).to have_graphql_fields(:jira_project_key, :createdAt, :scheduled_at, :scheduled_by)
end end
end end
...@@ -124,6 +124,7 @@ describe JiraImportState do ...@@ -124,6 +124,7 @@ describe JiraImportState do
jira_import.schedule jira_import.schedule
expect(jira_import.jid).to eq('some-job-id') expect(jira_import.jid).to eq('some-job-id')
expect(jira_import.scheduled_at).to be_within(1.second).of(Time.now)
end end
end end
......
...@@ -18,6 +18,7 @@ describe 'query Jira import data' do ...@@ -18,6 +18,7 @@ describe 'query Jira import data' do
jiraImports { jiraImports {
nodes { nodes {
jiraProjectKey jiraProjectKey
createdAt
scheduledAt scheduledAt
scheduledBy { scheduledBy {
username username
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment