Skip to content

Commit

Permalink
Merge pull request #17 from BlocSoc-iitr/v0.1
Browse files Browse the repository at this point in the history
Partial V0.1
  • Loading branch information
Sh0g0-1758 authored Sep 15, 2024
2 parents 83dbe60 + 9000ffb commit 5e0dad3
Show file tree
Hide file tree
Showing 69 changed files with 2,851 additions and 23,027 deletions.
Binary file removed .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
check
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to Athena

The Blocsoc team maintains guidelines for contributing to the Blocsoc repos. Check out our [website](https://blocsoc.iitr.ac.in/) if you want to learn more about us.

Also, give a read to our [code of conduct](./CODE_OF_CONDUCT.md) if you haven't already.

## Bugs and Feature Request

Before you make your changes, check to see if an [issue](https://github.com/BlocSoc-iitr/Athena/issues) exists already for the change you want to make.

### Opening issues

If you spot something new or want to change something, please make sure there isn't already an [issue](https://github.com/BlocSoc-iitr/Athena/issues) related to it.

If no issue addresses your problem, please open a new one with an accurate description of the problem. Please add, if possible, labels to have an overview of what they are targetting, and having an easier time filtering them out.

### Making Pull Requests

When you're done making changes and you'd like to propose them for review through a Pull Request.
Please make sure the PR mentions the related issue, detailing the changes made and potential side effects.

If your PR is not ready for review and merge because you are still working on it, please convert it to a draft.

## DOs and DON'Ts

Please do:

* **DO** give priority to the current style of the project or file you're changing even if it diverges from the general guidelines.
* **DO** include tests when adding new features. When fixing bugs, start with adding a test that highlights how the current behavior is broken.

Please do not:

* **DON'T** copy paste code from other data decoder implementations without a good argument to back it up.
* **DON'T** surprise us with big pull requests. Instead, file an issue and start a discussion so we can agree on a direction before you invest a large amount of time.

## Setting Up Git Hooks

To ensure code quality and consistency, this project uses a custom pre-commit hook. Follow these steps to set up the pre-commit hook:

Run the setup script to install the pre-commit hook:

```bash
chmod +x ./setup-hooks.sh
./setup-hooks.sh
```

This script will copy the pre-commit hook from the githooks directory to your local .git/hooks directory.

Verify that the pre-commit hook is installed and executable by running:

```bash
ls -l .git/hooks/pre-commit
```

You should see that the pre-commit file is listed and has executable permissions.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
unit:
@echo "Running unit tests"
go test ./athena_abi

unit-verbose:
@echo "Running unit tests in verbose mode"
go test -v ./athena_abi

clean:
@echo "Cleaning up"
go clean
5 changes: 3 additions & 2 deletions addresses.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package athena
//not implemented
package athena

//not implemented
32 changes: 17 additions & 15 deletions athena/backfill/exporters.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,30 @@ const (
Events BackfillDataType = "events"
Traces BackfillDataType = "traces"
)
//here the value stored inside the enum becomes the string

//here the value stored inside the enum becomes the string

// AbstractResourceExporter is the base class for resource exporters.
type AbstractResourceExporter struct {
exportMode ExportMode
initTime time.Time
resourcesSaved int
}
//use pointer as allow the actual value modification

// use pointer as allow the actual value modification
func (e *AbstractResourceExporter) Init() {
e.initTime = time.Now()
e.resourcesSaved = 0
}

func (e *AbstractResourceExporter) Close() {
duration := time.Since(e.initTime)
// Convert duration to minutes and seconds
minutes := int(duration / time.Minute)
seconds := int(duration % time.Minute / time.Second)
fmt.Printf("Exported %d rows in %d minutes and %d seconds\n", e.resourcesSaved, minutes, seconds)

// Convert duration to minutes and seconds
minutes := int(duration / time.Minute)
seconds := int(duration % time.Minute / time.Second)

fmt.Printf("Exported %d rows in %d minutes and %d seconds\n", e.resourcesSaved, minutes, seconds)
}

func (e *AbstractResourceExporter) EncodeDataclassAsDict(dataclass map[string]interface{}) map[string]interface{} {
Expand All @@ -71,7 +73,7 @@ type FileResourceExporter struct {
writer *csv.Writer
}

func NewFileResourceExporter(fileName string, append bool) (*FileResourceExporter, error) {//constructor function or init funct
func NewFileResourceExporter(fileName string, append bool) (*FileResourceExporter, error) { //constructor function or init funct
if !strings.HasSuffix(fileName, ".csv") {
return nil, errors.New("export file name must be a .csv file")
}
Expand All @@ -96,14 +98,14 @@ func NewFileResourceExporter(fileName string, append bool) (*FileResourceExporte
exporter := &FileResourceExporter{
fileName: fileName,
writeHeaders: false,
csvSeparator: "|",//unless specified explicitly this will remain the default value same as in python where there is no way to explicitly define this
csvSeparator: "|", //unless specified explicitly this will remain the default value same as in python where there is no way to explicitly define this
fileHandle: fileHandle,
writer: writer,
}
exporter.Init()

// Check if file is empty to determine if headers should be written
fileInfo, err := fileHandle.Stat()//has variuos methods defined on it like name , size , mode permissions and modification time etc
fileInfo, err := fileHandle.Stat() //has variuos methods defined on it like name , size , mode permissions and modification time etc
if err != nil {
return nil, err
}
Expand All @@ -114,7 +116,7 @@ func NewFileResourceExporter(fileName string, append bool) (*FileResourceExporte
return exporter, nil
}

func (e *FileResourceExporter) CSVEncodeValue(val interface{}) (string, error) {//[]interface{} holds value of any type just like a list in python --> this is only in a slice mde by using []
func (e *FileResourceExporter) CSVEncodeValue(val interface{}) (string, error) { //[]interface{} holds value of any type just like a list in python --> this is only in a slice mde by using []
switch v := val.(type) {
case nil:
return "", nil
Expand All @@ -134,9 +136,9 @@ func (e *FileResourceExporter) CSVEncodeValue(val interface{}) (string, error) {
return "[" + strings.Join(encodedList, ",") + "]", nil
case []byte:
return fmt.Sprintf("%x", v), nil
case map[string]interface{}://doesnt matter if key is string as not used in implementation
//interface{} can store any value in it
encodedMap, err := json.Marshal(v)//This function call converts the map v into a JSON-encoded byte slice. The json.Marshal function serializes Go values into JSON format
case map[string]interface{}: //doesnt matter if key is string as not used in implementation
//interface{} can store any value in it
encodedMap, err := json.Marshal(v) //This function call converts the map v into a JSON-encoded byte slice. The json.Marshal function serializes Go values into JSON format
if err != nil {
return "", err
}
Expand Down
Loading

0 comments on commit 5e0dad3

Please sign in to comment.