Skip to content

Commit 3c76070

Browse files
ksaricHirotoShioi
authored andcommitted
[TSD-97] to_be_analysed tag removed by debugger. (#46)
* [TSD-97] to_be_analysed tag removed by debugger. * [TSD-97] Fix import formatting.
1 parent 354ee35 commit 3c76070

File tree

4 files changed

+127
-20
lines changed

4 files changed

+127
-20
lines changed

src/DataSource/Http.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,11 @@ postTicketComment ticketInfo zendeskResponse = do
212212
createResponseTicket :: Integer -> TicketInfo -> ZendeskResponse -> Ticket
213213
createResponseTicket agentId TicketInfo{..} ZendeskResponse{..} =
214214
let analyzedTag = renderTicketStatus AnalyzedByScriptV1_3
215-
-- Nub so it won't post duplicate tags
216-
mergedTags = TicketTags . nub $ [analyzedTag] <> getTicketTags tiTags <> getTicketTags zrTags
215+
-- Nub so it won't post duplicate tags
216+
allTags = nub $ [analyzedTag] <> getTicketTags tiTags <> getTicketTags zrTags
217+
-- We remove the @ToBeAnalyzed@ tag.
218+
mergedTags = TicketTags . filter (/= renderTicketStatus ToBeAnalyzed) $ allTags
219+
217220
in (Ticket
218221
(Comment (CommentId 0)
219222
(CommentBody zrComment)

src/DataSource/Types.hs

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import Network.HTTP.Simple (Request)
7171

7272
import LogAnalysis.Types (Knowledge)
7373

74-
import Test.QuickCheck (Arbitrary (..), elements, listOf1, vectorOf)
74+
import Test.QuickCheck (Arbitrary (..), sublistOf, elements, listOf1)
7575

7676
------------------------------------------------------------
7777
-- Configuration
@@ -420,7 +420,7 @@ newtype TicketURL = TicketURL
420420

421421
newtype TicketTags = TicketTags
422422
{ getTicketTags :: [Text] -- TODO(ks): We need to fix the @TicketTag@ / @TicketTags@ story.
423-
} deriving (Eq, Show, Ord, Generic, FromJSON, ToJSON)
423+
} deriving (Eq, Show, Ord, Generic, Semigroup, FromJSON, ToJSON)
424424

425425
newtype TicketStatus = TicketStatus
426426
{ getTicketStatus :: Text
@@ -535,8 +535,108 @@ instance Arbitrary TicketStatus where
535535

536536
instance Arbitrary TicketTags where
537537
arbitrary = do
538-
numberOfTag <- arbitrary
539-
tagsList <- map fromString <$> vectorOf numberOfTag arbitrary
538+
-- curl https://iohk.zendesk.com/api/v2/tags.json -v -u $EMAIL/token:$TOKEN | jq '.tags | .[] | .name'
539+
-- Without `analyzed-by-script` and `goguen_testnets`
540+
let possibleTags :: [Text]
541+
possibleTags =
542+
[ "english"
543+
, "sev_3"
544+
, "daedalus_0.10.1_cardano_1.2.1"
545+
, "windows_10"
546+
, "daedalus_wallet"
547+
, "s3"
548+
, "wallet_application"
549+
, "connection"
550+
, "no-log-files"
551+
, "generic"
552+
, "cannot_sync_blocks"
553+
, "japanese"
554+
, "cannot_connect"
555+
, "delayed_reply"
556+
, "reply_resolved"
557+
, "install_latest_release"
558+
, "syncing"
559+
, "no-known-issues"
560+
, "web_widget"
561+
, "network-error"
562+
, "miscellaneous"
563+
, "connection-refused"
564+
, "cannot-connect"
565+
, "closed_by_merge"
566+
, "ask_for_info"
567+
, "time-out-of-sync"
568+
, "directory-not-found"
569+
, "db-corrupted"
570+
, "iohks-28"
571+
, "unknown"
572+
, "stale-lock-file"
573+
, "resource-vanished"
574+
, "error"
575+
, "global-time"
576+
, "sent-log-corrupted"
577+
, "pass_to_dev"
578+
, "cannot_connect_to_wallet_using_network"
579+
, "to_be_analysed"
580+
, "lite_wallet"
581+
, "operation"
582+
, "restore"
583+
, "traffic_censored"
584+
, "lost_recovery_prase"
585+
, "chinese"
586+
, "lost_password"
587+
, "already_exists"
588+
, "cannot_see_transaction"
589+
, "support"
590+
, "lost_ada"
591+
, "macos_10.13"
592+
, "user-name-error"
593+
, "windows_7"
594+
, "daniel_categorization"
595+
, "installation"
596+
, "short-storage"
597+
, "transaction"
598+
, "go_to_cardano_hub"
599+
, "issue_with_using_the_wallet"
600+
, "balance"
601+
, "login_feature"
602+
, "daedalus"
603+
, "spam"
604+
, "backup"
605+
, "app_cannot_sync_to_network"
606+
, "incorrect-balance"
607+
, "software_release"
608+
, "windows_8"
609+
, "wallet-backup"
610+
, "reply"
611+
, "coin_redemption"
612+
, "cannot-sync"
613+
, "how_to_buy_ada"
614+
, "missing_field_config_file"
615+
, "balance_mismatch"
616+
, "macos_10.11"
617+
, "wallet_balance_zero"
618+
, "iohks-44"
619+
, "where_is_cert"
620+
, "other"
621+
, "testnet_goguen_v1.0"
622+
, "scam"
623+
, "port_in_use"
624+
, "open.lock_file"
625+
, "cannot-download"
626+
, "testnet_goguen"
627+
, "staking"
628+
, "macos_10.12"
629+
, "security"
630+
, "no_disk_space"
631+
, "cannot-restore"
632+
, "can-not-sync"
633+
, "linux"
634+
, "problem_solved_by_release"
635+
, "sev3"
636+
, "linux_beta"
637+
, "russian"
638+
]
639+
tagsList <- sublistOf possibleTags
540640
pure . TicketTags $ tagsList
541641

542642
instance Arbitrary TicketURL where

src/Lib.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ listAndSortTickets = do
395395

396396
Config{..} <- ask
397397

398-
listAgents <- asksDataLayer zlListAdminAgents
399-
agents <- listAgents
398+
listAgents <- asksDataLayer zlListAdminAgents
399+
agents <- listAgents
400400

401401
let agentIds :: [UserId]
402402
agentIds = map uId agents
@@ -406,7 +406,7 @@ listAndSortTickets = do
406406

407407
printText "Classifier is going to process tickets assigned to agents"
408408

409-
ticketInfos <- map concat $ traverse listTickets agentIds
409+
ticketInfos <- map concat $ traverse listTickets agentIds
410410

411411
let filteredTicketIds = filterAnalyzedTickets ticketInfos
412412
let sortedTicketIds = sortBy compare filteredTicketIds

test/Spec.hs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ module Main where
22

33
import Universum
44

5+
import Data.List (nub)
6+
57
import Test.Hspec (Spec, describe, hspec, it, pending, shouldBe)
68
import Test.Hspec.QuickCheck (modifyMaxSuccess)
7-
import Test.QuickCheck (Gen, arbitrary, elements, forAll, listOf, listOf1, property)
9+
import Test.QuickCheck (Gen, arbitrary, elements, forAll, listOf, listOf1, property,
10+
(===))
811
import Test.QuickCheck.Monadic (assert, monadicIO, pre, run)
912

10-
import Configuration (defaultConfig, basicIOLayer)
11-
import DataSource (App, Attachment (..), Comment (..), Config (..), DeletedTicket (..),
12-
ExportFromTime (..), IOLayer (..), Ticket (..), TicketId (..),
13-
TicketInfo (..), TicketStatus (..), TicketTags (..), User, UserId (..),
14-
ZendeskAPIUrl (..), DataLayer (..), ZendeskResponse (..),
15-
createResponseTicket , runApp, showURL, emptyDBLayer, emptyDataLayer)
13+
import Configuration (basicIOLayer, defaultConfig)
14+
import DataSource (App, Attachment (..), Comment (..), Config (..), DataLayer (..),
15+
DeletedTicket (..), ExportFromTime (..), IOLayer (..), Ticket (..),
16+
TicketId (..), TicketInfo (..), TicketStatus (..), TicketTag (..),
17+
TicketTags (..), User, UserId (..), ZendeskAPIUrl (..),
18+
ZendeskResponse (..), createResponseTicket, emptyDBLayer,
19+
emptyDataLayer, renderTicketStatus, runApp, showURL)
1620
import Exceptions (ProcessTicketExceptions (..))
1721

1822
import Lib (exportZendeskDataToLocalDB, filterAnalyzedTickets, listAndSortTickets,
@@ -494,11 +498,11 @@ createResponseTicketSpec =
494498
it "should preserve tags from ticketinfo and zendeskresponse" $
495499
property $ \agentId ticketInfo zendeskResponse ->
496500
let responseTicket = createResponseTicket agentId ticketInfo zendeskResponse
497-
ticketInfoTags = getTicketTags (tiTags ticketInfo)
498-
zendeskResponseTags = getTicketTags (zrTags zendeskResponse)
499-
mergedTags = ticketInfoTags <> zendeskResponseTags
501+
mergedTags = getTicketTags $ tiTags ticketInfo <> zrTags zendeskResponse
500502
responseTags = getTicketTags $ tTag responseTicket
501-
in all (`elem` responseTags) mergedTags
503+
-- in summary, the response tags have the debuggers `analyzed-by-script-version` tag AND
504+
-- they remove the `to_be_analysed` tag AND they are unique.
505+
in (filter (/= renderTicketStatus ToBeAnalyzed) . nub $ renderTicketStatus AnalyzedByScriptV1_3 : mergedTags) === responseTags
502506

503507

504508
exportZendeskDataToLocalDBSpec :: Spec

0 commit comments

Comments
 (0)