Skip to content

Comments

Lint remaining services#2458

Merged
elland merged 2 commits intodevelopfrom
lint-remainder-services
Jun 9, 2022
Merged

Lint remaining services#2458
elland merged 2 commits intodevelopfrom
lint-remainder-services

Conversation

@elland
Copy link
Contributor

@elland elland commented Jun 8, 2022

And that's the lest of /services. Next, tools and libs!

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.

@elland elland temporarily deployed to cachix June 8, 2022 06:46 Inactive
Copy link
Contributor

@fisx fisx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment, i'd like to see this changed into something not more obfuscating, but less. but i'll leave it to the author to second-guess me.

Comment on lines +189 to +196
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly disagree. what does hlint say if we put brackets around dryRun <$> askMigEnv in the original code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sold on this either… A few suggestions seem to be counter-productive when we have code like this.

Copy link
Contributor Author

@elland elland Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, redundant <$>. How about extracting the case match?

Something along these lines (needs a better name):

sink ::
  ( HasSpar env,
    HasLogger env,
    HasMigEnv env,
    HasFailCount env
  ) =>
  ConduitM [ResolveTeamResult] Void (RIO env) ()
sink = go
  where
    go = do
      mbResult <- await
      for_ mbResult $ \results -> do
        for_ results $ \case
          UserHasNoTeam uid extid -> do
            lift $ do
              modifyRef failCount (+ 1)
              dbg <- debug <$> askMigEnv
              when (dbg == Debug) $
                logDebug ("No team for user " <> show uid <> " from extid " <> show extid)
          NewExternalId (tid, extid, uid) ->
            lift $
              askMigEnv >>= whetherDryRun tid extid uid . dryRun
        go
    insert :: PrepQuery W (TeamId, Text, UserId) ()
    insert = "INSERT INTO scim_external (team, external_id, user) VALUES (?, ?, ?)"
    whetherDryRun tid extid uid = \case
      DryRun -> pure ()
      NoDryRun ->
        runSpar $
          write insert (params LocalQuorum (tid, extid, uid))

@elland elland force-pushed the lint-remainder-services branch from 3e6c4d3 to fd8d582 Compare June 9, 2022 07:25
@elland elland temporarily deployed to cachix June 9, 2022 07:25 Inactive
@elland elland force-pushed the lint-remainder-services branch from fd8d582 to 488bf54 Compare June 9, 2022 08:23
@elland elland temporarily deployed to cachix June 9, 2022 08:23 Inactive
@elland elland merged commit a557d17 into develop Jun 9, 2022
@elland elland deleted the lint-remainder-services branch June 9, 2022 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants