<commit_before>package io.toro.workshop.blog;

import java.util.List;

/**
 * Uses GoogleSheets as a data store for blogs
 */
public class GoogleSheetsBlogService implements BlogService {

    @Override
    public List<Blog> findBlogs() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Blog findBlog(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Blog saveBlog(Blog blog) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteBlogById(Long id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
<commit_msg>added gsheets endpionts<commit_after>package io.toro.workshop.blog;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;

import org.springframework.beans.factory.annotation.Autowired;

import io.toro.workshop.connectors.GoogleSheetsConnector;

/**
 * Uses GoogleSheets as a data store for blogs
 */
public class GoogleSheetsBlogService implements BlogService {

	private final GoogleSheetsConnector googleSheetsConnector;

	@Autowired
	public GoogleSheetsBlogService(GoogleSheetsConnector googleSheetsConnector) {
		this.googleSheetsConnector = googleSheetsConnector;
	}

	@Override
	public List<Blog> findBlogs() {
		List<Blog> cells = new ArrayList<>();
		try {
			cells = googleSheetsConnector.getAllCells();
		} catch (Exception e) {
			System.err.println("Oopps! Somethings wrong! " + e.getMessage().toString());
		}
		return cells;
	}

	@Override
	public Blog findBlog(Long id) {
		Blog blog = null;
		try {
			blog = googleSheetsConnector.getRowByID(googleSheetsConnector.findIndex(id));
		} catch (Exception e) {
			System.err.println("Oopps! Somethings wrong! " + e.getMessage().toString());
		}
		return blog;
	}

	@Override
	public Blog saveBlog(Blog blog) {
		Blog savedBlog = null;
		try {
			googleSheetsConnector.addListRow( blog.getId(), blog.getTitle(), blog.getContent() );
			savedBlog = googleSheetsConnector.getRowByID(googleSheetsConnector.findIndex(blog.getId()));
		} catch (Exception e) {
			System.err.println("Oopps! Somethings wrong! " + e.getMessage().toString());
		}
		return savedBlog;
	}

	@Override
	public void deleteBlogById(Long id) {
		try {
			googleSheetsConnector.deleteRow( googleSheetsConnector.findIndex(id) );
		} catch (Exception e) {
			System.err.println("Oopps! Somethings wrong! " + e.getMessage().toString());
		}
	}

}

{'fraction_non_alphanumeric': 0.11010617381046009, 'fraction_numerical': 0.0, 'mean_word_length': 4.278008298755187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2371946', 'n_tokens_mistral': 824, 'n_tokens_neox': 780, 'n_words': 172}