Chunking
This commit is contained in:
1 parent
f54aaa6e95
commit
f5197caa77
7 files changed
+259
-69
No files matched your search
+5
-5
@@ -152,13 +152,13 @@ sourceEntries s = P.unfoldr (toEither <=< go) (Just startUrl) >-> P.mapFoldable
|
||||
Everything -> "https://app.wallabag.it/api/entries.json"
|
||||
go :: Maybe String -> m (Maybe ([Value], Maybe String))
|
||||
go Nothing = pure Nothing
|
||||
go (Just url) = checkpoint (Annotation url) $ do
|
||||
go (Just u) = checkpoint (Annotation u) $ do
|
||||
metrics <- mkTracerMetrics
|
||||
t <- maybe (throw MissingTokenException) pure =<< getToken
|
||||
let opts = defaults & header "Authorization" .~ ["Bearer " <> t ^. re utf8]
|
||||
K.logFM K.DebugS $ K.ls ("Fetching entries '" <> url <> "'")
|
||||
K.logFM K.DebugS $ K.ls ("Fetching entries '" <> u <> "'")
|
||||
session <- view $ typed @Session
|
||||
r <- liftIO $ getWith metrics session SafeTransient opts url
|
||||
r <- liftIO $ getWith metrics session SafeTransient opts u
|
||||
let items = r ^.. responseBody . key "_embedded" . key "items" . _Array . traversed
|
||||
let next = r ^? responseBody . key "_links" . key "next" . key "href" . _String . unpacked
|
||||
pure $ Just (items, next)
|
||||
@@ -202,8 +202,8 @@ applyTags e = checkpoint (Annotation $ e ^. identifier) $ do
|
||||
t <- maybe (throw MissingTokenException) pure =<< getToken
|
||||
let opts = defaults & header "Authorization" .~ ["Bearer " <> t ^. re utf8]
|
||||
K.logFM K.InfoS (K.ls ("Applying tags for '" <> e ^. title <> "': " <> T.pack (show (e ^. tags))))
|
||||
let url = "https://app.wallabag.it/api/entries/" <> show (e ^. identifier) <> "/tags"
|
||||
let u = "https://app.wallabag.it/api/entries/" <> show (e ^. identifier) <> "/tags"
|
||||
metrics <- mkTracerMetrics
|
||||
session <- view $ typed @Session
|
||||
_ <- liftIO $ postWith metrics session SafeTransient opts url ["tags" := T.intercalate "," (e ^. tags)]
|
||||
_ <- liftIO $ postWith metrics session SafeTransient opts u ["tags" := T.intercalate "," (e ^. tags)]
|
||||
pure ()
|
||||
Reference in new issue
Block a user