Skip to content

Instantly share code, notes, and snippets.

@kamal-kambe
Last active August 6, 2019 07:14
Show Gist options
  • Select an option

  • Save kamal-kambe/e40c05adcd4101362ba4c34e2ac67860 to your computer and use it in GitHub Desktop.

Select an option

Save kamal-kambe/e40c05adcd4101362ba4c34e2ac67860 to your computer and use it in GitHub Desktop.

Revisions

  1. kamal-kambe revised this gist Aug 6, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions base.go
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ import (
    )

    type Base interface {
    GetDiff(lastVersion uint) json.RawMessage
    GetData() json.RawMessage
    }

    type base struct {
    @@ -20,7 +20,7 @@ func (f *baseFactory) NewBase() Base {
    }
    }

    func (b *base) GetData(lastVersion uint) json.RawMessage {
    func (b *base) GetData() json.RawMessage {
    data := make(map[string]interface{})

    updatedModels := b.bRepo.GetUpdatedModels()
  2. kamal-kambe revised this gist Aug 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion base.go
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ func (f *baseFactory) NewBase() Base {
    func (b *base) GetData(lastVersion uint) json.RawMessage {
    data := make(map[string]interface{})

    updatedModels := b.bRepo.GetUpdatedModels()
    updatedModels := b.bRepo.GetUpdatedModels()
    data["market_data"] := b.bRepo.GetRows(updatedModels)

    jsonData, _ := json.Marshal(data)
  3. kamal-kambe created this gist Aug 1, 2019.
    31 changes: 31 additions & 0 deletions base.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    package service

    import (
    "encoding/json"
    )

    type Base interface {
    GetDiff(lastVersion uint) json.RawMessage
    }

    type base struct {
    bRepo BaseRepository
    cache Cache
    }

    func (f *baseFactory) NewBase() Base {
    return &base{
    bRepo: f.NewBaseRepository(),
    cache: f.cache,
    }
    }

    func (b *base) GetData(lastVersion uint) json.RawMessage {
    data := make(map[string]interface{})

    updatedModels := b.bRepo.GetUpdatedModels()
    data["market_data"] := b.bRepo.GetRows(updatedModels)

    jsonData, _ := json.Marshal(data)
    return jsonData
    }