Skip to content

Commit

Permalink
Mailchimp: Remove everything
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed Dec 2, 2024
1 parent 0b71a0b commit 32abb0c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 264 deletions.
19 changes: 0 additions & 19 deletions internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions internal/db/page.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 0 additions & 62 deletions internal/mailchimp/import.go

This file was deleted.

119 changes: 0 additions & 119 deletions internal/mailchimp/parse_test.go

This file was deleted.

28 changes: 0 additions & 28 deletions pkg/almanack/service-page.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"maps"
"net/http"
"strings"

"github.com/carlmjohnson/errorx"
Expand All @@ -18,7 +17,6 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/spotlightpa/almanack/internal/arc"
"github.com/spotlightpa/almanack/internal/db"
"github.com/spotlightpa/almanack/internal/mailchimp"
"github.com/spotlightpa/almanack/internal/stringx"
"github.com/spotlightpa/almanack/internal/timex"
"github.com/spotlightpa/almanack/pkg/almlog"
Expand Down Expand Up @@ -362,29 +360,3 @@ func (svc Services) Notify(ctx context.Context, page *db.Page, publishingNow boo
},
})
}

func (svc Services) RefreshPageFromMailchimp(ctx context.Context, page *db.Page) (err error) {
defer errorx.Trace(&err)

id := page.ID
archiveURL, err := svc.Queries.GetArchiveURLForPageID(ctx, id)
if err != nil {
return err
}
if archiveURL == "" {
return resperr.New(http.StatusConflict, "no archiveURL for page %d", id)
}

body, err := mailchimp.ImportPage(ctx, svc.Client, archiveURL)
if err != nil {
return err
}
*page, err = svc.Queries.UpdatePageRawContent(ctx, db.UpdatePageRawContentParams{
ID: id,
RawContent: body,
})
if err != nil {
return err
}
return nil
}
12 changes: 4 additions & 8 deletions pkg/api/routes-spotlightpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,6 @@ func (app *appEnv) postPageRefresh(w http.ResponseWriter, r *http.Request) {
}

switch page.SourceType {
case "mailchimp":
err = app.svc.RefreshPageFromMailchimp(r.Context(), &page)
if err != nil {
app.replyErr(w, r, err)
return
}
app.replyJSON(http.StatusOK, w, &page)
return
case "gdocs":
dbDoc, err := app.svc.Queries.GetGDocsByExternalIDWhereProcessed(r.Context(), page.SourceID)
if err != nil {
Expand Down Expand Up @@ -648,6 +640,10 @@ func (app *appEnv) postPageRefresh(w http.ResponseWriter, r *http.Request) {
page.Body = dbDoc.ArticleMarkdown
app.replyJSON(http.StatusOK, w, &page)
return
case "mailchimp":
app.replyNewErr(http.StatusConflict, w, r, "can not refresh source-type mailchimp; id=%d", id)
return

case "arc":
app.replyNewErr(http.StatusConflict, w, r, "can not refresh source-type arc; id=%d", id)
return
Expand Down
10 changes: 0 additions & 10 deletions sql/queries/page.sql
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ FROM
ORDER BY
array_position(query_paths.paths, url_path::text);

-- name: GetArchiveURLForPageID :one
SELECT
coalesce(archive_url, '')
FROM
page
LEFT JOIN newsletter ON page.source_id = newsletter.id::text
AND page.source_type = 'mailchimp'
WHERE
page.id = $1;

-- name: UpdatePageRawContent :one
UPDATE
page
Expand Down
4 changes: 4 additions & 0 deletions sql/schema-overrides/001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ ALTER TABLE page

ALTER TABLE image
DROP COLUMN fts;

DROP TABLE newsletter;

DROP TABLE newsletter_type;

0 comments on commit 32abb0c

Please sign in to comment.