Conversation
fisx
approved these changes
Jun 8, 2022
Contributor
fisx
left a comment
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
I strongly disagree. what does hlint say if we put brackets around dryRun <$> askMigEnv in the original code?
Contributor
Author
There was a problem hiding this comment.
Yeah, I'm not sold on this either… A few suggestions seem to be counter-productive when we have code like this.
Contributor
Author
There was a problem hiding this comment.
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))3e6c4d3 to
fd8d582
Compare
fd8d582 to
488bf54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
And that's the lest of /services. Next, tools and libs!
Checklist