Skip to content

Commit

Permalink
Add links (#14)
Browse files Browse the repository at this point in the history
* Add links

* Fix spoeadic unit tests

* Enable go cache in CI

* Enable go cache in main

* Fix typos
  • Loading branch information
heppu committed Mar 18, 2024
1 parent fad6a4a commit 2a870ca
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: elisa-actions/setup-go-and-mage@v1
with:
go-cache: true

- name: Verify deps
run: mage go:tidyAndVerify
Expand Down Expand Up @@ -38,7 +40,7 @@ jobs:
TAGS: latest sha-${{ github.sha }}
run: mage image:build

- name: Build image
- name: Smoke test
env:
TAG: sha-${{ github.sha }}
run: mage image:smokeTest
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: elisa-actions/setup-go-and-mage@v1
with:
go-cache: true

- name: Verify deps
run: mage go:tidyAndVerify
Expand Down Expand Up @@ -47,7 +49,7 @@ jobs:
TAGS: sha-${{ github.event.pull_request.head.sha }}
run: mage image:build

- name: Build image
- name: Smoke test image
env:
TAG: sha-${{ github.event.pull_request.head.sha }}
run: mage image:smokeTest
12 changes: 9 additions & 3 deletions api/broadcaster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ func TestBroadcasterStuckClient(t *testing.T) {
_, unsubscribe := b.Subscribe(api.NoFilter, true)
defer unsubscribe()

ready := make(chan struct{})

// Receive all events regardless of the stuck client.
go func() {
defer close(done)
counter := 0
ch, unsubscribe := b.Subscribe(api.NoFilter, true)
defer unsubscribe()
close(ready)
for {
select {
case <-ch:
Expand All @@ -114,7 +117,7 @@ func TestBroadcasterStuckClient(t *testing.T) {
}
}()

time.Sleep(time.Second)
<-ready
for i := 0; i < numOfEvents; i++ {
s.events <- model.Event{}
}
Expand All @@ -130,20 +133,22 @@ func TestBroadcasterRetry(t *testing.T) {
events: make(chan model.Event, 1000),
}

b := api.NewBroadcaster(s, time.Millisecond*10)
b := api.NewBroadcaster(s, time.Second)

eg := &multierror.Group{}
eg.Go(b.Run)

const numOfEvents = 2 * api.BufferSize
done := make(chan struct{})

// Receive all events regardless of the stuck client.
ready := make(chan struct{})
// Receive all events with bit of sleep to trigger retry.
go func() {
defer close(done)
counter := 0
ch, unsubscribe := b.Subscribe(api.NoFilter, true)
defer unsubscribe()
close(ready)
for {
select {
case <-ch:
Expand All @@ -160,6 +165,7 @@ func TestBroadcasterRetry(t *testing.T) {
}
}()

<-ready
for i := 0; i < numOfEvents; i++ {
s.events <- model.Event{}
}
Expand Down
24 changes: 17 additions & 7 deletions api/templates/index.templ
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@ templ Table(events []model.Event, query url.Values) {
}

templ Row(e model.Event) {
<div class="tr"><div class="left"><div class="td"><span class={ "tag", e.State }>{ e.State }</span></div><div class="td">{ e.TxID }</div></div><div class="right"><div class="td">{ e.ProverID }</div><div class="td"><span class="datetime">{ e.Timestamp.Format("03:04 PM, 02/01/06") }</span></div><div class="td">→</div></div></div>
<div class="tr">
<div class="left">
<div class="td"><span class={ "tag", e.State }>{ e.State }</span></div>
<div class="td">{ e.TxID }</div>
</div>
<div class="right">
<div class="td">{ e.ProverID }</div>
<div class="td"><span class="datetime">{ e.Timestamp.Format("03:04 PM, 02/01/06") }</span></div>
<div class="td">→</div>
</div>
</div>
}

templ head() {
Expand Down Expand Up @@ -130,13 +140,13 @@ templ header() {

templ footer() {
<div id="footer">
<div id="copyright">Copyright ©2024 - Gevulot</div>
<div id="copyright">Copyright ©{ time.Now().Format("2006") } - Gevulot</div>
<div id="links">
<a href="">Twitter</a>
<a href="">Telegram</a>
<a href="">Substack</a>
<a href="">Github</a>
<a href="">We're hiring</a>
<a href="https://twitter.com/gevulot_network" target="_blank">Twitter</a>
<a href="https://t.me/gevulot" target="_blank">Telegram</a>
<a href="https://substack.com/profile/183978644-gevulot" target="_blank">Substack</a>
<a href="https://github.com/gevulotnetwork/gevulot" target="_blank">Github</a>
<a href="https://www.notion.so/gevulot/Gevulot-open-positions-21aba554609745cb84644bf00f9ace6d" target="_blank">We're hiring</a>
</div>
</div>
}
Expand Down
23 changes: 18 additions & 5 deletions api/templates/index_templ.go

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

8 changes: 6 additions & 2 deletions store/pg/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ func (s *Store) Stats() (model.Stats, error) {
}

func (s *Store) Search(filter string) ([]model.Event, error) {
const query = `` // TODO: implement search query
// TODO: implement search query
//
// filter string: free text search input straight from the user, handle as such.
// This query should return 50 most recent matching events sorted by timestamp in newest first order.
const query = ``
var events []model.Event
if _, err := s.db.Select(&events, query); err != nil {
if _, err := s.db.Select(&events, query, filter); err != nil {
return nil, err
}

Expand Down

0 comments on commit 2a870ca

Please sign in to comment.