Compare commits

..

No commits in common. "21013d7e40d1e513fb160727536921291591bcb4" and "94f4593fdc1cef08d2730dee8b0e59f956dd0bf3" have entirely different histories.

4 changed files with 46 additions and 30 deletions

View File

@ -1,12 +1,32 @@
{
"nodes": {
"easy-hls": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1637250802,
"narHash": "sha256-/crlHEVB148PGQLZCsHOR9L5qgvCAfRSocIoKgmMAhA=",
"owner": "jkachmar",
"repo": "easy-hls-nix",
"rev": "7c123399ef8a67dc0e505d9cf7f2c7f64f1cd847",
"type": "github"
},
"original": {
"owner": "jkachmar",
"repo": "easy-hls-nix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
@ -17,11 +37,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1650440614,
"narHash": "sha256-7mF7gyS5P3UmZmQuo9jbikP2wMyRUnimI7HcKLJ9OZQ=",
"lastModified": 1644453163,
"narHash": "sha256-VPlXtIsShceYHUspnJSvuvucrX1OWVFmrqiofn69yCM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0bbb65673c0ba31047c9ba6c4cd211556b534a4e",
"rev": "7e003d7fb9eff8ecb84405360c75c716cdd1f79f",
"type": "github"
},
"original": {
@ -31,6 +51,7 @@
},
"root": {
"inputs": {
"easy-hls": "easy-hls",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}

View File

@ -2,13 +2,17 @@
description = "A very basic flake";
inputs = {
easy-hls = {
url = "github:jkachmar/easy-hls-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils }:
outputs = { self, nixpkgs, flake-utils, easy-hls }:
{
overlay = final: prev: {
haskellPackages = prev.haskellPackages.override ( old: {
@ -23,6 +27,7 @@
let
pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
hp = pkgs.haskellPackages;
hls = (easy-hls.withGhcs [ hp.ghc.version ] ).${system};
in
rec {
@ -43,6 +48,7 @@
hp.hlint
stylish-haskell
ghcid
hls
rrdtool
jq
sqlite-interactive
@ -52,8 +58,6 @@
hp.graphmod
hp.dhall-nixpkgs
hp.haskell-language-server
];
};
}

View File

@ -40,7 +40,7 @@ library
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>=4.15.1.0
build-depends: base ^>=4.14.1.0
, amqp
, aeson
, lens
@ -65,7 +65,7 @@ executable reddit-pub
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends:
base ^>=4.15.1.0,
base ^>=4.14.1.0,
reddit-pub
hs-source-dirs: app
@ -82,7 +82,7 @@ test-suite reddit-tests
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends:
base ^>=4.15.1.0,
base ^>=4.14.1.0,
mtl,
containers,
bytestring,

View File

@ -2,25 +2,20 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module MyLib (defaultMain) where
import Control.Concurrent (threadDelay)
import Control.Exception (bracket)
import Control.Lens
import Control.Monad (forever, void)
import Control.Monad (void)
import Data.Aeson (FromJSON, ToJSON, Value)
import qualified Data.Aeson as A
import Data.Aeson.Lens (_String, key)
import Data.Bool (bool)
import Data.Config
import Data.Deriving.Aeson
import Data.Foldable (for_)
import Data.Functor.Contravariant ((>$<))
import Data.Text (Text)
import qualified Data.Text.IO as TI
import qualified Data.Text.Strict.Lens as T
import qualified Database.SQLite.Simple as SQL
import GHC.Generics (Generic)
@ -28,21 +23,19 @@ import qualified Membership
import Network.AMQP
( Channel
, DeliveryMode(Persistent)
, closeConnection
, declareExchange
, exchangeName
, exchangeType
, msgBody
, msgDeliveryMode
, newExchange
, newMsg
, openChannel
, openConnection
, publishMsg
, publishMsg, openConnection, closeConnection, openChannel, newExchange, declareExchange
)
import Network.Reddit (RedditId(RedditId), publishEntries)
import Network.Reddit (RedditId (RedditId), publishEntries)
import Network.Wreq.Session (newSession)
import Publish (Publish(..))
import Data.Aeson.Lens (key, _String)
import Data.Bool (bool)
import qualified Data.Text.IO as TI
data MessageType = Create | Update
deriving stock (Show, Eq, Generic)
@ -93,11 +86,9 @@ defaultMain path = do
let encoder = amqpPublisher sqlConn chan "reddit_posts"
recorder = sqlRecorder sqlConn
publisher = encoder <> (messageIdentifier >$< recorder)
forever $ do
for_ (conf ^. fetchers) $ \fetcher -> do
print fetcher
publishEntries (toMessage >$< publisher) sess fetcher
threadDelay (15 * 60_000_000)
for_ (conf ^. fetchers) $ \fetcher -> do
print fetcher
publishEntries (toMessage >$< publisher) sess fetcher
getPassword :: Password -> IO Text
getPassword (Password p) = pure p