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
class JiraImportType < BaseObject
graphql_name 'JiraImport'
field :scheduled_at, Types::TimeType, null: true,
method: :created_at,
field :created_at, Types::TimeType, null: true,
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,
description: 'User that started the Jira import'
field :jira_project_key, GraphQL::STRING_TYPE, null: false,
......
......@@ -46,7 +46,7 @@ class JiraImportState < ApplicationRecord
after_transition initial: :scheduled do |state, _|
state.run_after_commit do
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
......
---
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 (
status smallint DEFAULT 0 NOT NULL,
jid character varying(255),
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
......@@ -13521,6 +13522,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200423080334
20200423080607
20200423081409
20200423101529
20200424050250
20200427064130
\.
......
......@@ -4509,13 +4509,18 @@ Represents untyped JSON
scalar JSON
type JiraImport {
"""
Timestamp of when the Jira import was created
"""
createdAt: Time
"""
Project key for the imported Jira project
"""
jiraProjectKey: String!
"""
Timestamp of when the Jira import was created
Timestamp of when the Jira import was scheduled
"""
scheduledAt: Time
......
......@@ -12767,6 +12767,20 @@
"name": "JiraImport",
"description": null,
"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",
"description": "Project key for the imported Jira project",
......@@ -12787,7 +12801,7 @@
},
{
"name": "scheduledAt",
"description": "Timestamp of when the Jira import was created",
"description": "Timestamp of when the Jira import was scheduled",
"args": [
],
......
......@@ -677,8 +677,9 @@ Autogenerated return type of IssueSetWeight
| Name | Type | Description |
| --- | ---- | ---------- |
| `createdAt` | Time | Timestamp of when the Jira import was created |
| `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 |
## JiraImportStartPayload
......
......@@ -6,6 +6,6 @@ describe GitlabSchema.types['JiraImport'] do
it { expect(described_class.graphql_name).to eq('JiraImport') }
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
......@@ -124,6 +124,7 @@ describe JiraImportState do
jira_import.schedule
expect(jira_import.jid).to eq('some-job-id')
expect(jira_import.scheduled_at).to be_within(1.second).of(Time.now)
end
end
......
......@@ -18,6 +18,7 @@ describe 'query Jira import data' do
jiraImports {
nodes {
jiraProjectKey
createdAt
scheduledAt
scheduledBy {
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