<commit_before>package model

import (
	"github.com/garyburd/redigo/redis"
	"log"
	"time"
	"strconv"
"github.com/evolsnow/samaritan/conn"
)

//All model's redis actions

func getPassword(id int) string {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	pwd, _ := redis.String(c.Do("HGET", user, "passwd"))
	return pwd
}

func updatePassword(id int, pwd string) {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	_, err := c.Do("HSET", user, "passwd", pwd)
	if err != nil {
		log.Println("Failed to update password for user:%s", id)
	}
}

func readUser(id int) (reply []interface{}, err error) {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	reply, err = redis.Values(c.Do("HGETALL", user))
	return
}

func readMissionRcv(mid int, uids []int) ([]interface{}, err error) {
	c := conn.Pool.Get()
	defer c.Close()
	replys := make([]interface{}, len(uids))
	receiverSet := "mission:receivers" + strconv.Itoa(mid)
	//todo luc

	return replys, nil
}

func readMission(mid int) (reply []interface{}, err error) {
	c := conn.Pool.Get()
	defer c.Close()
	mission := "mission:" + strconv.Itoa(mid)
	reply, err = redis.Values(c.Do("HGETALL", mission))
	return
}

func updateMissionRcv(mid, uid int) (err error) {
	c := conn.Pool.Get()
	defer c.Close()
	receiverSet := "mission:receivers" + strconv.Itoa(mid)
	_, err = c.Do("SADD", receiverSet, uid)
	return
}

func createMission(m *Mission){

}<commit_msg>split redis actions<commit_after>package model

import (
	"github.com/evolsnow/samaritan/conn"
	"github.com/garyburd/redigo/redis"
	"log"
	"strconv"
	"time"
)

//All model's redis actions

func getPassword(id int) string {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	pwd, _ := redis.String(c.Do("HGET", user, "passwd"))
	return pwd
}

func updatePassword(id int, pwd string) {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	_, err := c.Do("HSET", user, "passwd", pwd)
	if err != nil {
		log.Println("Failed to update password for user:%s", id)
	}
}

func readUser(id int) (reply []interface{}, err error) {
	c := conn.Pool.Get()
	defer c.Close()
	user := "user:" + strconv.Itoa(id)
	reply, err = redis.Values(c.Do("HGETALL", user))
	return
}

func readMissionRcv(mid int, uids []int) ([]interface{}, error) {
	c := conn.Pool.Get()
	defer c.Close()
	replys := make([]interface{}, len(uids))
	receiverSet := "mission:receivers" + strconv.Itoa(mid)
	//todo luc

	return replys, nil
}

func readMission(mid int) (reply []interface{}, err error) {
	c := conn.Pool.Get()
	defer c.Close()
	mission := "mission:" + strconv.Itoa(mid)
	reply, err = redis.Values(c.Do("HGETALL", mission))
	return
}

func updateMissionRcv(mid, uid int) (err error) {
	c := conn.Pool.Get()
	defer c.Close()
	receiverSet := "mission:receivers" + strconv.Itoa(mid)
	_, err = c.Do("SADD", receiverSet, uid)
	return
}

func createMission(m *Mission) {

}
{'fraction_non_alphanumeric': 0.1864864864864865, 'fraction_numerical': 0.0, 'mean_word_length': 4.325539568345324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6489638', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1197, 'n_words': 277}